DATA Step, Macro, Functions and more

Date format change

Reply
Occasional Contributor
Posts: 13

Date format change

Hi Team,
I am new in sas programming. Can anyone help me to build the logic of the below.
Here the date is assigned as a char And we are getting output in pdf as for example 03/03/2017. Now the requirement is to change the ouput date look to 03-MAR-17.
Please help me out how it is possible to do.

Thsnks,
Puja
Super User
Posts: 17,831

Re: Date format change

You need to show how you're using the date and we can then show you how to change the format. 

PROC Star
Posts: 7,363

Re: Date format change

1. Converting a character date to a SAS date: SASDateVariableName=input(yourdatevariable, anydtdte.);

2. Assign the desired format: format ASDateVariableName mmddyyD10.;

 

Other variants of that format can be found at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000590662.htm

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 5,083

Re: Date format change

Well, I would never show you have to get a date with a two-digit year.  I hope this is close enough:

 

data want;

length mydate $ 11;

set have;

mydate = put(input(mydate, mmddyy10.), date11.);

run;

 

That's assuming that 03/03/2017 is actually in MMDDYY form, rather than DDMMYY form.

Ask a Question
Discussion stats
  • 3 replies
  • 119 views
  • 0 likes
  • 4 in conversation