Hello
I'm working on a data which has numeric variable in the following way.
20061213
20061213
20061213
20061214
I tried converting it in to date format by using following code.
data TEST;
set recnou.rec19sep17;
format dtmep date8. ;
where CDFPRO='P';
keep nocont cnp dtmep unpaid;
run;
I'm getting following output.
********
********
********
********
********
********
********
********
********
can any one please tell me the reason for the above output and how do I rectify the problem.
i want the date to be mm/dd/yyyy
Thank you
You can't format it as a date because for that to work, the number has to be a legitimate SAS date value, in other words, it must be the number of days since Jan 1, 1960. Try this UNTESTED CODE
newvar=input(put(dtmep,$8.),yymmdd8.);
format newvar date8.;
i solve it right this
data TEST;
set recnou.rec19sep17;
DATE2 = INPUT(PUT(Dtmep,8.),yyMMDD8.);
FORMAT DATE2 MMDDYY10.;
where CDFPRO='P';
keep nocont cnp date2 unpaid;
run;
You can't format it as a date because for that to work, the number has to be a legitimate SAS date value, in other words, it must be the number of days since Jan 1, 1960. Try this UNTESTED CODE
newvar=input(put(dtmep,$8.),yymmdd8.);
format newvar date8.;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.