Help using Base SAS procedures

SAS Date MMM-YY

Accepted Solution Solved
Reply
Regular Contributor
Posts: 173
Accepted Solution

SAS Date MMM-YY

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;


Accepted Solutions
Solution
‎10-13-2012 09:28 AM
Super Contributor
Posts: 1,636

Re: SAS Date MMM-YY

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


All Replies
Solution
‎10-13-2012 09:28 AM
Super Contributor
Posts: 1,636

Re: SAS Date MMM-YY

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

Regular Contributor
Posts: 173

Re: SAS Date MMM-YY

Hi Linlin,

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

Thank you guys!!

Super User
Super User
Posts: 7,060

Re: SAS Date MMM-YY

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

Regular Contributor
Posts: 173

Re: SAS Date MMM-YY

Tom,

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

Thank you again Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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