BookmarkSubscribeRSS Feed
hk2013
Fluorite | Level 6

I have date in DDMMYYYY (29mar2018) format and i want to convert it to MMM-YYYY (Mar-2018) 

2 REPLIES 2
TomKari
Onyx | Level 15
data Example;
	length OutDate $8;
	InDate = "29mar2018";
	SASDateValue = input(InDate, date9.);
	format SASDateValue date9.;
	OutDate = put(SASDateValue, monname3.)||"-"||put(SASDateValue, year4.);
run;
ballardw
Super User

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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1158 views
  • 0 likes
  • 3 in conversation