Hi Everyone,
I want to create a macro variable that take the value of today date in the form yyyymmdd.
I can do it with my code below but I have to start with a dataset "mydata".
I thought that there should be a way to use _NULL_ data but I cant work it out.
Can you help me?
Thank you,
HC
*SOLUTION --------------------------------
data _NULL_;
format today yymmdd8.;
today=date();
ymd=year(today)*10000+month(today)*100+day(today);
call symputx('next_month',put(ymd,10.));
run;
%put &next_month;
data TEMP; set Mydata;
format today yymmdd8.;
today=date();
ymd=year(today)*10000+month(today)*100+day(today);run;
proc sql;
select Max(ymd) into:todaydate
from TEMP;quit;
%put &todaydate;
I don't really understand what your question is.
You do not need to have an input dataset to run a data step.
data _null_;
x=today();
next_month=intnx('month',x,1,'b');
call symputx('next_month',put(next_month,yymmddn8.));
run;
Look up %SYSFUNC and note the two parameters.
%let today = %sysfunc(today(), yymmdd8.);
%put &today.;
Thank you for the suggestion.
I am more concern with manipulating the value a bit before passing it to macro variable.
HC
hi,
Check out "CALL SYMPUT" which can pass the value to a macro variable with DATA _NULL_
I don't really understand what your question is.
You do not need to have an input dataset to run a data step.
data _null_;
x=today();
next_month=intnx('month',x,1,'b');
call symputx('next_month',put(next_month,yymmddn8.));
run;
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.