DATA Step, Macro, Functions and more

Convert $5 formatted variable to ddmmyy date??

Reply
N/A
Posts: 0

Convert $5 formatted variable to ddmmyy date??

Ok, I've been on holiday for the past week and seem to have lost all SAS ability. All I'm looking to do is convert a $5 formatted variable to a ddmmyy. date.

For example, I want the value 'JAN11' to be converted to '01JAN11'.

Can anyone help?

Many thanks
Super Contributor
Super Contributor
Posts: 365

Re: Convert $5 formatted variable to ddmmyy date??

Posted in reply to deleted_user
Hello Wacattack,

This is a code:
[pre]
data a;
d="jan11";
date=INPUT("01"||d,anydtdte7.);
format date date7.;
run;
[/pre]
Sincerely,
SPR
N/A
Posts: 0

Re: Convert $5 formatted variable to ddmmyy date??

Thanks mate, works perfectly
Respected Advisor
Posts: 3,799

Re: Convert $5 formatted variable to ddmmyy date??

The specific INFORMAT is MONYY

[pre]
116 data _null_;
117 x = 'jan11';
118 d = input(x,monyy.);
119 put d=date9. d=monyy.;
120 run;

d=01JAN2011 d=JAN11
[/pre]
Ask a Question
Discussion stats
  • 3 replies
  • 150 views
  • 0 likes
  • 3 in conversation