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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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