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;
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.