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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 485 views
  • 0 likes
  • 3 in conversation