I have this:
%let yyyymm=202109;
data temp;
format yearmonth monyy7.;
yearmonth=&yyyymm.;
run;
The resulting yearmonth variable has value "MAY2513"
Want:
It should be 'SEP2021'
If you want the variable YEARMONTH to work with a date type format, such as MONYY, then it has to have date values, not random numbers like 202,109.
yearmonth=input("&yyyymm.01",yymmdd8.);
@david27
In SAS 202,109 is a number it is not a date. SAS stores dates as the number of days since 01/01/1960 (day 0), so 202109 is a day in May 2513.
What you need to do is convert 2021-09 into a SAS date value
There's a number of ways to do this, probably the simplest is the MDY function
Please review the documentation links and feel free to ask any additional questions
%let yyyymm=202109;
data temp;
format yearmonth monyy7.;
yearmonth=input("&yyyymm.", yymmn6.);
run;
proc print;run;
@david27 wrote:
I have this:
%let yyyymm=202109;
data temp;
format yearmonth monyy7.;
yearmonth=&yyyymm.;
run;The resulting yearmonth variable has value "MAY2513"
Want:
It should be 'SEP2021'
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: