Hello everyone,
I created a macrovariable within a macro to do some checks. After that there is some more SAS Coding. I need to have &report_date. and &report_date_prev. as global macrovariables because they are also used in my SAS-coding after the macro, because right now after executing the %macro check, the macro variables are not definded for the whole proram
I can not build the macro around the whole code.
%Macro check; data _null_; report_date_prev=intnx("month",today(),-1,"E"); call symputx ("report_date_prev",report_date_prev); run; data current_month; set SOME TABLE; if start_date > &report_date_prev.; run; proc sql noprint; select min(start_date) format 8. into :start_date from current_month; quit; data _NULL_ ; report_date=intnx("weekday",intnx("month",today(),0,"B"),2); call symputx ("report_date", report_date); run; %if %eval(&start_date. le &report_date.) %then %do; %put Data ok; %end; %else %do; %PUT ERROR: Data is not updated; %abort; %end; %mend; %check;
Thank you for your help
Hi,
one way:
call symputx ("report_date", report_date, "G"); /* G - global */
other way:
%GLOBAL report_date;
data ...;
call symputx ("report_date", report_date);
Bart
Hi,
one way:
call symputx ("report_date", report_date, "G"); /* G - global */
other way:
%GLOBAL report_date;
data ...;
call symputx ("report_date", report_date);
Bart
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.