BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KevinC_
Fluorite | Level 6

Hello Everyone,

I am trying to format a SAS date from MMMYY to MMM-YY  (i.e. OCT12 to OCT-12).

This is the code.  I can't figure out how to add a - between the month and the year.

Thank you for input you may have!

proc  format ;

picture fmt(default=5)

other='%b%y'(datatype=date);

run;

data _null_;

a=23234;

format a fmt.;

put a= ;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

Hi,

proc  format ;

picture fmt(default=6)

other='%b-%y'(datatype=date);

run;

data want;

a=23234;

format a fmt.;

proc print;run;

Message was edited by:Linlin

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

Hi,

proc  format ;

picture fmt(default=6)

other='%b-%y'(datatype=date);

run;

data want;

a=23234;

format a fmt.;

proc print;run;

Message was edited by:Linlin

KevinC_
Fluorite | Level 6

Hi Linlin,

Thank you very much for your reply and suggestions!  I really learned something new today.

Thank you guys!!

Tom
Super User Tom
Super User

Just include the hyphen in the picture format text. You might also want to look at the built in format NLDATEYM.

proc  format ;

  picture fmtA(default=5) other='%b%y'(datatype=date);

  picture fmtB(default=6) other='%b-%y'(datatype=date);

run;


data _null_;

  a='13OCT2012'd ;

  put a= date9. / a fmtA. / a fmtB. / a  nldateym6. ;

run;

a=13OCT2012

OCT12

OCT-12

Oct 12

KevinC_
Fluorite | Level 6

Tom,

That worked beautifully!  I really appreciate your input and suggestions.  That was awesome!!

Thank you again Smiley Happy

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 9219 views
  • 4 likes
  • 3 in conversation