dm"log;clear;output;clear";
DATA pumpkins1;
infile datalines dlm="," dsd;
length name $16 ;
input name $ age type $ EnterDate mmddyy10. (j1-j5);
DATALINES;
Alicia Grossman,13,C,10-28-2008,7.8,6.5,7.2,8.0,7.9
Matthew Lee,9,D,10-30-2008,6.5,5.9,6.8,6.0,8.1
Elizabeth Garcia,10,C,10-29-2008,8.9,7.9,8.5,9.0,
,6,D,10-30-2008,6.7,5.6,4.9,5.2,6.1
Jose Martinez,7,D,10-31-2008,8.9,,10.0,9.7,9.0
Brian Williams,11,C,10-29-2008,7.8,8.4,8.5,7.9,8.0
;
RUN;
PROC PRINT data = pumpkins1;
format Enterdate mmddyy10.;
RUN;
my output is attached
Because the date variable is read using formatted input (not list input), the input pointer stops before the comma that follows the date.
The software starts looking for J1, and then hits the comma so J1 is missing. (Notice how the remaining variables J2-J5 are reading the values that you actually intended for J1-J4.)
An easy fix: change the INPUT statement to move past that comma:
input name $ age type $ EnterDate mmddyy10. +1 (j1-j5);
That's untested code, but should resolve the problem.
I cann't explain why but I changed the INFILE statment and the INPUTstatement, until it worked fine:
INFILE DATALINES DLM="," TRUNCOVER;
input name $ age type $ EnterDate mmddyy10. j1-j5;
Should be:
DATA pumpkins1;
infile datalines dsd; /* dsd implies dlm="," */
length name $16 ;
input name $ age type $ EnterDate :mmddyy10. j1-j5; /* Check list input in the doc */
DATALINES;
Alicia Grossman,13,C,10-28-2008,7.8,6.5,7.2,8.0,7.9
Matthew Lee,9,D,10-30-2008,6.5,5.9,6.8,6.0,8.1
Elizabeth Garcia,10,C,10-29-2008,8.9,7.9,8.5,9.0,
,6,D,10-30-2008,6.7,5.6,4.9,5.2,6.1
Jose Martinez,7,D,10-31-2008,8.9,,10.0,9.7,9.0
Brian Williams,11,C,10-29-2008,7.8,8.4,8.5,7.9,8.0
;
/* run; Not required after datalines; */
PROC PRINT data = pumpkins1;
format Enterdate mmddyy10.;
RUN;
Great question. You can either use an INFORMAT statement or use an informat modifier (:).
informat EnterDate mmddyy10.;
input name $ age type $ EnterDate j1-j5;
-OR-
input name $ age type $ EnterDate : mmddyy10. j1-j5;
Please read the link the documentation that i provided.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.