Hi
I have a SAS date as a macro variable as follows:
%let Date_selected = 01Feb2022
I want to extract the month as a two digit no from this.
(eg: FEB => month_no = 02,
Mar => month_no = 03,
Apr => month_no = 04
etc).
With SYMPUTX I can get the month as a digit but not in 2 digit format.
call symputx("month_no",put("&Date_selected"d,month.)); /*this gives month_no = 2*/
Can someone help me with this?
Thanks
Why call symputx?
%let Date_selected = 01Feb2022;
%let m = %sysfunc(month("&date_selected."d), z2.);
Try this
%let Date_selected = 01Feb2022;
data _null_;
m = put(month("&Date_selected"d), z2.);
call symputx('m', m);
run;
%put &m.;
Why call symputx?
%let Date_selected = 01Feb2022;
%let m = %sysfunc(month("&date_selected."d), z2.);
Thank you very much 🙏 You saved my life
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.