I am receiving an error message with the below code. What do I need to add on the infile statement?
data cltrials;
infile datalines truncover ;
input Name : $ TestDate $ Sex $ Placebo : $ Cholesterol 3. Triglyc 3. Uric 3.1;
*format TestDate date9.;
datalines;
Johnson 22MAY2000 F YES 200 180 3.7
Eberhardt 22MAY2000 F NO 244 320 4.6
Nunnelly 22MAY2000 F YES 210 300 4.0
Johnson 01AUG2000 F YES 205 185 3.8
Eberhardt 01AUG2000 F NO 249 325 4.7
Nunnelly 01AUG2000 F YES 215 305 4.1
Johnson 09AUG2000 F YES 215 190 3.9
Eberhardt 09AUG2000 F NO 254 330 4.8
Nunnelly 09AUG2000 F YES 220 310 4.2
;
run;
error message:
3478 data cltrials;
3479
3480 infile datalines dsd;
3481
3482 input Name : $ TestDate $ Sex $ Placebo : $ Cholesterol 3. Triglyc 3. Uric 3.1;
3483
3484 *format TestDate date9.;
3485
3486 datalines;NOTE: Invalid data for Cholesterol in line 3491 1-3.
NOTE: Invalid data for Triglyc in line 3491 4-6.
NOTE: Invalid data for Uric in line 3491 7-9.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
3491 Eberhardt 01AUG2000 F NO 249 325 4.7
Name=Johnson TestDate=Eberhard Sex=Nunnelly Placebo=Johnson Cholesterol=. Triglyc=. Uric=. _ERROR_=1 _N_=1
NOTE: LOST CARD.
3496 ;
Name=Nunnelly TestDate=Johnson Sex=Eberhard Placebo=Nunnelly Cholesterol=. Triglyc=. Uric=. _ERROR_=1 _N_=2
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.CLTRIALS has 1 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
3496 ;
3497 run;
The program in your picture is expecting commas between the values because it used the DSD option and did not override the comma delimiter that option implies.
The program in your picture is expecting commas between the values because it used the DSD option and did not override the comma delimiter that option implies.
Additionally do not use the decimals on list input unless you really know what an implied decimal means. It may even be better for numeric values to just leave the informat off entirely. If you specify an informat like 3. and encounter a value of 9999 you will not have a numeric value of 9999 but 999 (or 99.9 if using 3.1).
data cltrials; infile datalines truncover ; input Name : $20. TestDate : date9. Sex $ Placebo $ Cholesterol Triglyc Uric ; format TestDate date9.; datalines; Johnson 22MAY2000 F YES 200 180 3.7 Eberhardt 22MAY2000 F NO 244 320 4.6 Nunnelly 22MAY2000 F YES 210 300 4.0 Johnson 01AUG2000 F YES 205 185 3.8 Eberhardt 01AUG2000 F NO 249 325 4.7 Nunnelly 01AUG2000 F YES 215 305 4.1 Johnson 09AUG2000 F YES 215 190 3.9 Eberhardt 09AUG2000 F NO 254 330 4.8 Nunnelly 09AUG2000 F YES 220 310 4.2 ; run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.