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....!
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;
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;
Also, it is good practice to have some delimiter between your data values.
Makes it much easier to work with 🙂
Thanks very much for your help.....!
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.