Sorry beginner here How to make SAS read the date, when I proc print there's nothing print for dates
DATA bp;
INFILE DATALINES;
input id ;
$4 dob : mmddyy10. $4 admit : mmddyy10. $4 dischrg : mmddyy10. fee ;
DATALINES;
001 10/21/1946 12/12/2004 12/14/2004 8000
002 05/01/1980 07/08/2004 08/08/2004 12000
003 01/01/1960 01/01/2004 01/04/2004 9000
004 06/23/1998 11/11/2004 12/25/2004 15123
run;
PROC PRINT DATA= bp;
RUN;
DATA bp;
INFILE DATALINES;
input id
$3. dob : mmddyy10. admit : mmddyy10. dischrg : mmddyy10. fee ;
format dob admit dischrg mmddyy10.;;
DATALINES;
001 10/21/1946 12/12/2004 12/14/2004 8000
002 05/01/1980 07/08/2004 08/08/2004 12000
003 01/01/1960 01/01/2004 01/04/2004 9000
004 06/23/1998 11/11/2004 12/25/2004 15123
run;
PROC PRINT DATA= bp;
RUN;
Obs | id | dob | admit | dischrg | fee |
---|---|---|---|---|---|
1 | 001 | 10/21/1946 | 12/12/2004 | 12/14/2004 | 8000 |
2 | 002 | 05/01/1980 | 07/08/2004 | 08/08/2004 | 12000 |
3 | 003 | 01/01/1960 | 01/01/2004 | 01/04/2004 | 9000 |
4 | 004 | 06/23/1998 | 11/11/2004 | 12/25/2004 | 15123 |
DATA bp;
INFILE DATALINES;
input id
$3. dob : mmddyy10. admit : mmddyy10. dischrg : mmddyy10. fee ;
format dob admit dischrg mmddyy10.;;
DATALINES;
001 10/21/1946 12/12/2004 12/14/2004 8000
002 05/01/1980 07/08/2004 08/08/2004 12000
003 01/01/1960 01/01/2004 01/04/2004 9000
004 06/23/1998 11/11/2004 12/25/2004 15123
run;
PROC PRINT DATA= bp;
RUN;
Obs | id | dob | admit | dischrg | fee |
---|---|---|---|---|---|
1 | 001 | 10/21/1946 | 12/12/2004 | 12/14/2004 | 8000 |
2 | 002 | 05/01/1980 | 07/08/2004 | 08/08/2004 | 12000 |
3 | 003 | 01/01/1960 | 01/01/2004 | 01/04/2004 | 9000 |
4 | 004 | 06/23/1998 | 11/11/2004 | 12/25/2004 | 15123 |
Thank you so much!, why do you use $3 instead $4 i don't understand the $ sign, is that mean by columns? 3rd column?
Hi @Lvp8906 The instruction that is given using Input statement goes like this:
$3- $ dollar stands for the value to be read a character. 3 bytes of character to be read from the input buffer into the PDV to the build the observation. 001 002 appears only 3 bytes with 1 byte of space for each character.
Yes one column position contains value of 1 byte
@Lvp8906 - $3. defines how SAS reads the ID data. $ means read the data as character, 3 means read the first three columns of data.
DATA bp;
INFILE DATALINES;
input id $3. (dob admit dischrg) (: anydtdte.) fee ;
format dob admit dischrg mmddyy10.;
DATALINES;
001 10/21/1946 12/12/2004 12/14/2004 8000
002 05/01/1980 07/08/2004 08/08/2004 12000
003 01/01/1960 01/01/2004 01/04/2004 9000
004 06/23/1998 11/11/2004 12/25/2004 15123
run;
PROC PRINT DATA= bp;
RUN;
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.