BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
texasmfp
Lapis Lazuli | Level 10

I have a macro variable defined inside a program (program1) for a fudge factor.

 

%LET fudge = 1.00;

When I run that program as a standalone, I want it to remain at 1.00.

 

However, I have another program (program2) that calls up and runs program1 several times; each time replacing the value of fudge factor. 

 

%LET fudge 	= 1.01;				/* Total number in subset */
%include "&PATH\&hmprog";
%include "&PATH\&usprog";

%LET fudge 	= 1.02;				/* Total number in subset */
%include "&PATH\&hmprog";
%include "&PATH\&usprog";

%LET fudge 	= 1.03;				/* Total number in subset */
%include "&PATH\&hmprog";
%include "&PATH\&usprog";

%LET fudge 	= 1.04;				/* Total number in subset */
%include "&PATH\&hmprog";
%include "&PATH\&usprog";

%LET fudge 	= 1.05;				/* Total number in subset */
%include "&PATH\&hmprog";
%include "&PATH\&usprog";

While I can manually edit the called program1 to delete the "%LET fudge = 1.00;" line and resave, I was hoping there was a way to avoid that.  That is, to have the macro variable's value in program2 override the 1.00 value in program1 without having to manually edit that line out and resave (and then reverse it when I want to run program1 as a standalone).

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You could use code as below in your program1 to only create and populate macro variable &fudge if it doesn't exist already.

data _null_;
  if not symexist("fudge") then 
    do;
      call symputx('fudge','1.00');
    end;
    stop;
run;

 

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

You could use code as below in your program1 to only create and populate macro variable &fudge if it doesn't exist already.

data _null_;
  if not symexist("fudge") then 
    do;
      call symputx('fudge','1.00');
    end;
    stop;
run;

 

texasmfp
Lapis Lazuli | Level 10
Thanks. I love SAS Communities!!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 343 views
  • 0 likes
  • 2 in conversation