BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Aayushi_17
Quartz | Level 8

Hi ,

 

How to convert the date if it is month and day format for eg.         

Date Required output 
19 APR 04-19

 

how to get the required output.

Thanks in advance 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

So you do have a string consisting of two parts, separated by a blank, the first part the numeric day of a month, the second the month name in capitals?

 

Since you do not have a date (because the year is missing), you first need to add a year (which is unimportant), so you can then use a custom picture format:

proc format;
picture mdd
  low-high = '%0m-%0d' (datatype=date)
;
run;

data test;
have = "19 APR";
want = put(input(compress(have)!!"2022",date9.),mdd.);
run;

proc print data=test noobs;
run;

Result:

have	want
19 APR	04-19

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

Afaik there is no format displaying month and day. Check the docs about picture formats, i am sure that such a format could be created.

Kurt_Bremser
Super User

So you do have a string consisting of two parts, separated by a blank, the first part the numeric day of a month, the second the month name in capitals?

 

Since you do not have a date (because the year is missing), you first need to add a year (which is unimportant), so you can then use a custom picture format:

proc format;
picture mdd
  low-high = '%0m-%0d' (datatype=date)
;
run;

data test;
have = "19 APR";
want = put(input(compress(have)!!"2022",date9.),mdd.);
run;

proc print data=test noobs;
run;

Result:

have	want
19 APR	04-19
Aayushi_17
Quartz | Level 8

Thank you thats working

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 950 views
  • 0 likes
  • 3 in conversation