BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nikhil_1393
Calcite | Level 5

DATA BIRTHDATES;
INPUT ID $ 1-5 GENDER $ 6 MARRIED 7 BDATE 8-16 ;
FORMAT BDATE WORDDATE18.;
DATALINES;
00001M112JAN1999
00021F003MAR1989
00043F018JUL1991
00054M022DEC1998
00132F110JUL1992
;
Title "FRIEND'S BIRTHDATES";
PROC PRINT DATA=BIRTHDATES;
RUN;

 

 

In this example my output is showing the BDATE column as blank despite specifying  the  DATE format for the same.Please help me out....!

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Use the date9 informat on BDATE to tell SAS how to read it

 

data birthdates;
input id $ 1-5 gender $ 6 married 7 bdate:date9.;
format bdate worddate18.;
datalines;
00001m112jan1999
00021f003mar1989
00043f018jul1991
00054m022dec1998
00132f110jul1992
;

title "friend's birthdates";
proc print data=birthdates;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Use the date9 informat on BDATE to tell SAS how to read it

 

data birthdates;
input id $ 1-5 gender $ 6 married 7 bdate:date9.;
format bdate worddate18.;
datalines;
00001m112jan1999
00021f003mar1989
00043f018jul1991
00054m022dec1998
00132f110jul1992
;

title "friend's birthdates";
proc print data=birthdates;
run;
PeterClemmensen
Tourmaline | Level 20

Also, it is good practice to have some delimiter between your data values. 

 

Makes it much easier to work with 🙂

Nikhil_1393
Calcite | Level 5

Thanks very much for your help.....!

euro_andres
Fluorite | Level 6

Hello My friend,

 

As everyone said  you need to use an informat. Keep in mind that formats is the way information is shown in an output while INformat is the way information is read from an external source.

 

Hope this helps.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 973 views
  • 6 likes
  • 3 in conversation