Hi Techies,
I came across a requirement to concatenate month and year and from that concat I have to get the previous month end.
I tried with PUT(mdy(t1.MONTH_NUMBER, 1, t1.YEAR_WORKED),MMDDYY10.) and I am getting like 03/01/2016 if the month is MARCH and theYEAR is 2016, in this case.
here is the data I am having
Data having :
YEAR_WORKED MONTH_NAME DATE_WANTED
2016 MARCH 28FEB2016
2016 APRIL 31MAR2016
2016 NOVEMBER 31OCT2016
2017 FEBRUARY 31JAN2017
2017 MARCH 28FEB2017
2018 APRIL 31MAR2018
2018 MAY 30APR2018
2018 SEPTEMBER 31AUG2018
Really appreciate if some one Could please help me .
Thanks,
Vickys
Do like this
data have;
input year_worked month_name :$15.;
datalines;
2016 MARCH
2016 APRIL
2016 NOVEMBER
2017 FEBRUARY
2017 MARCH
2018 APRIL
2018 MAY
2018 SEPTEMBER
;
data want;
set have;
date_wanted=input(cats(substr(MONTH_NAME, 1, 3), YEAR_WORKED), monyy7.)-1;
format date_wanted date9.;
run;
Do like this
data have;
input year_worked month_name :$15.;
datalines;
2016 MARCH
2016 APRIL
2016 NOVEMBER
2017 FEBRUARY
2017 MARCH
2018 APRIL
2018 MAY
2018 SEPTEMBER
;
data want;
set have;
date_wanted=input(cats(substr(MONTH_NAME, 1, 3), YEAR_WORKED), monyy7.)-1;
format date_wanted date9.;
run;
Thanks Draycut.
really appreciate your help
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.