0
votes

I am a complete newb to SAS and I only know is basic sql. Currently taking Regression class and having trouble with SAS code.

I am trying to input two columns of data where x variable is State; y variable is # of accidents for a simple regression.

I keep getting this: ERROR: No valid observations are found. Number of Observations Read 51 Number of Observations Used 0 Number of Observations with Missing Values 51

Is it because datalines only read numbers and not charcters? Here is the code as well as the datalines:

Data Firearm_Accidents_1999_to_2014;
ods graphics on;
Input State Sum_OF_Deaths;
Datalines;
Alabama 526
Alaska  0
Arizona 150
Arkansas    246
California  834
Colorado    33
Connecticut 0
Delaware    0
District_of_Columbia    0
Florida 350
Georgia 413
Hawaii  0
Idaho   0
Illinois    287
Indiana 288
Iowa    0
Kansas  44
Kentucky    384
Louisiana   562
Maine   0
Maryland    21
Massachusetts   27
Michigan    168
Minnesota   0
Mississippi 332
Missouri    320
Montana 0
Nebraska    0
Nevada  0
New_Hampshire   0
New_Jersey  85
New_Mexico  49
New_York    218
North_Carolina  437
North_Dakota    0
Ohio    306
Oklahoma    227
Oregon  41
Pennsylvania    465
Rhode_Island    0
South_Carolina  324
South_Dakota    0
Tennessee   603
Texas   876
Utah    0
Vermont 0
Virginia    203
Washington  45
West_Virginia   136
Wisconsin   64
Wyoming 0
;
run; proc print; 

proc reg data = Firearm_Accidents_1999_to_2014;         
    model State = Sum_OF_Deaths;        
ods graphics off;
run; quit;
1
Read about informats and delimiters , that would create your dataset.in_user

1 Answers

0
votes

OK, some different levels of issues here.

  1. ODS GRAPHICS go before and after procs, not inside them.
  2. When reading a character variable you need to tell SAS using an informat.

This allows you to read in the data. However your regression has several issues. For one, State is a character variable and you can do regression with a character variable. I think that issue is beyond this forum. Review your regression basics and check what you're trying to do.

Data Firearm_Accidents_1999_to_2014;
    informat state $32.;
    Input State Sum_OF_Deaths;
    Datalines;
Alabama 526
Alaska  0
Arizona 150
Arkansas    246
California  834
Colorado    33
....
;
run;