I am getting the error below for the attached data input statement and I am not sure what the problem is or how to fix it. I am assuming it might have something to do with the ' .' for missing data? Thanks for your help!
1811 Data MTcontywage ;
1812 input name $15. wage state county;
1813 format county z3. wage dollar10.2;
1814 Datalines;
NOTE: LOST CARD.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----
1873 ;
name= wage=. state=. county=. _ERROR_=1 _N_=58
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.MTCONTYWAGE has 57 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
1873 ;
here is the data file
What is happening is you are in one way or another telling SAS it is supposed to read past the end of the data line.
Specific to this case you have a completely blank line of data before the semicolon ending the datalines.
So when SAS tried to read that line it didn't find anything and started to look on the next (non existent) line to finish the input statement. The unconditional format for name is forced to attempt to read something.
Data MTcontywage ; input name $15. wage state county; format county z3. wage dollar10.2; Datalines; Beaverhead 9.98 30 001 Big Horn 16.49 30 003 Blaine 11.35 30 005 Broadwater 12.17 30 007 Carbon 11.92 30 009 Cascade 11.12 30 013 Carter . 30 011 Chouteau 10.00 30 015 Custer 11.57 30 017 Daniels 9.33 30 019 Dawson 10.13 30 021 Deer Lodge 12.20 30 023 Fallon 12.00 30 025 Fergus 12.50 30 027 Flathead 12.69 30 029 Gallatin 13.79 30 031 Garfield 10.75 30 033 Glacier 14.84 30 035 Golden Valley . 30 037 Granite 15.33 30 039 Hill 13.93 30 041 Jefferson 12.04 30 043 Judith Basin . 30 045 Lake 12.65 30 047 Lewis And Clark 12.65 30 049 Liberty 8.00 30 051 Lincoln 12.79 30 056 Madison 10.46 30 057 McCone 9.50 30 055 Meagher . 30 059 Mineral 11.05 30 061 Missoula 12.49 30 063 Musselshell 12.87 30 065 Park 13.62 30 067 Phillips 14.68 30 071 Petroleum . 30 069 Pondera 11.84 30 073 Powder River . 30 075 Prairie . 30 079 Powell 11.49 30 077 Ravalli 11.67 30 081 Richland 11.76 30 083 Roosevelt 15.38 30 085 Rosebud 11.67 30 087 Sanders 12.23 30 089 Sheridan 9.69 30 091 Silver Bow 10.69 30 093 Stillwater 9.77 30 095 Sweet Grass 10.20 30 097 Teton 12.00 30 099 Toole 10.49 30 101 Treasure . 30 103 Valley 13.29 30 105 Wheatland 10.72 30 107 Wibaux . 30 109 Yellowstone 11.98 30 111 YNP . 30 113 ;
Two things also:
1) Never leave a blank line in a datalines block.
2) You may want to think about adding: Infile datalines truncover;
The truncover (or other "over" options tell SAS what to do when the data line runs out of information
before the input statement is completed.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.