DATA Step, Macro, Functions and more

date in dd-mon-yyyy

Reply
Contributor
Posts: 37

date in dd-mon-yyyy

I'm using SAS 9.1. I want the date in the format 15-OCT-2012. I found a piece of code here that gets the year in a 2 digit format rather than 4 and I don't know how to change it.

proc format;

     picture date9x other='%0d-%b-%0y' (datatype=date);

run;

data _null_;

     call symputx('enddt',put(intnx('month',today(),-2,'end'),date9x.));

run;

%put enddt = &enddt.;

I get 31-DEC-12. I changed the last part to %Y and now I get 31-DEC-20.

How do I get 2012?

Respected Advisor
Posts: 3,124

Re: date in dd-mon-yyyy

proc format;

  picture date9x other='%0d-%b-%Y' (datatype=date);

run;

data _null_;

  call symputx('enddt',put(intnx('month',today(),-2,'end'),date9x11.));

run;

%put enddt = &enddt.;

Haikuo

Contributor
Posts: 37

Re: date in dd-mon-yyyy

That works. Thanks Haikuo.

Ask a Question
Discussion stats
  • 2 replies
  • 1332 views
  • 0 likes
  • 2 in conversation