I would appreciate if someone could help me with the SAS code to properly read the dataset below:
I have missing values and SAS log produced an error message.There were 21 obs but SAS read only 17.
Please help. Thanks. The SAS log is shown below.
data idnew1m;
input id$ job idchem;
datalines;
os1 1 990005
os1 1 990021
1 210701
os1 1 211700
os1 2 211700
os1 2 990021
os2 2
os1 2 210701
os1 2 990005
os2 1 210701
os2 211700
os2 1 990005
os2 2 990021
os2 3 210701
os2 3 990005
os3 3 210701
os3 1 211700
os4 1 210701
os4 1 990005
os4 1 211700
os5 990021
;
run;
proc print data=idnew1m;
run;
.
Thanks in advance.
ak.
If you want to use list mode input, like in your INPUT statement, then you need to have a value for every field. Use a period to indicate missing values (for both numeric and character variables).
data idnew1m;
input id$ job idchem;
datalines;
os1 1 990021
. 1 210701
os2 2 .
os2 . 211700
os4 1 211700
;
Or make sure the values are always in the same place on the line. Then you could switch to formattted input
data idnew1m;
input id $3. +1 job 1. +1 idchem 5.;
datalines;
os1 1 990021
1 210701
os2 2
os2 211700
os4 1 211700
;
or column based input.
data idnew1m;
input id $ 1-3 job 5 idchem 7-12 ;
datalines;
os1 1 990021
1 210701
os2 2
os2 211700
os4 1 211700
;
You could still use list mode if you used to the DSD option to interpret adjacent delimiters as representing a missing value. Normally you would use something other than space as the delimiter in that case.
data idnew1m;
infile datalines dsd dlm='|' truncover;
input id$ job idchem;
datalines;
os1|1|990021
|1|210701
os2|2|
os2||211700
os4|1|211700
;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.