I have date in DDMMYYYY (29mar2018) format and i want to convert it to MMM-YYYY (Mar-2018)
data Example;
length OutDate $8;
InDate = "29mar2018";
SASDateValue = input(InDate, date9.);
format SASDateValue date9.;
OutDate = put(SASDateValue, monname3.)||"-"||put(SASDateValue, year4.);
run;
SAS allows for the creation of your own date formats using the picture statement in proc format:
proc format library=work; picture mymonyy (default=8) low-high ='%b-%Y' (datatype=date); run;
If the value is an actual SAS date valued numeric then use the mymonyy. format for any procedure to display the value.
Note that in the code aboe the %b and %Y are case sensitive. Capitalization of the month will depend on your Local setting any you may want to try %3B if %b doesn't look the way you want.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.