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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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