SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lvp8906
Fluorite | Level 6

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20
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
Lvp8906
Fluorite | Level 6

Thank you so much!, why do you use $3 instead $4 i don't understand the $ sign, is that mean by columns? 3rd column? 

novinosrin
Tourmaline | Level 20

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

SASKiwi
PROC Star

@Lvp8906  - $3. defines how SAS reads the ID data. $ means read the data as character, 3 means read the first three columns of data.

r_behata
Barite | Level 11
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;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1143 views
  • 4 likes
  • 4 in conversation