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
Amethyst | Level 16

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
Amethyst | Level 16

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 957 views
  • 1 like
  • 2 in conversation