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