from a given date for ex. 1st nov 2013
1. assign the date in yyyy_mm format to a macro variable
2.Assign the date in MMM_YY foramt to a macro variable
Here it is.
data temp;
dt = today();
call symput('dt1', catx('_', year(dt), put(month(dt),2.)));
call symput('dt2', catx('_', substr(put(dt,date9.),3,3), substr(put(dt,date9.),8,2)));
run;
%put &dt1= &dt2=;
Answer to #1: %let macrovar=2013_11;
Answer to #2: should be obvious from answer to #1
Here it is.
data temp;
dt = today();
call symput('dt1', catx('_', year(dt), put(month(dt),2.)));
call symput('dt2', catx('_', substr(put(dt,date9.),3,3), substr(put(dt,date9.),8,2)));
run;
%put &dt1= &dt2=;
Thanks for your reply,it is helpful for me, giving correct result
Maybe this is what you mean. Your question is somewhat vague.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.