DATA Step, Macro, Functions and more

Formats

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Formats

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....!


Accepted Solutions
Solution
4 weeks ago
PROC Star
Posts: 1,193

Re: Formats

Posted in reply to Nikhil_1393

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


All Replies
Solution
4 weeks ago
PROC Star
Posts: 1,193

Re: Formats

Posted in reply to Nikhil_1393

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;
PROC Star
Posts: 1,193

Re: Formats

Posted in reply to Nikhil_1393

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

 

Makes it much easier to work with Smiley Happy

Occasional Contributor
Posts: 6

Re: Formats

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

New Contributor
Posts: 2

Re: Formats

Posted in reply to Nikhil_1393

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 163 views
  • 6 likes
  • 3 in conversation