BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jay_Aguilar
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Jay_Aguilar
Calcite | Level 5
Thank you very much

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 614 views
  • 1 like
  • 2 in conversation