I wrote one macro as below. This macro includes two parameters. If either of them is blank, the values of the two maco variable will be specified in the macro...........But when i run %test, error will appear.....How to fix it? Thanks.
%macro test(alpha,beta);
%if &alpha eq and &beta eq %then %do;
%let &alpha=0.005;
%let &beta=0.005;
%end;
%if &alpha ne and &beta eq %then %do;
%let &beta=α
%end;
%put &alpha β
%mend;
%test()
try this one:
%macro test(alpha,beta);
%if &alpha eq and &beta eq %then %do;
%let alpha=0.005;
%let beta=0.005;
%end;
%if &alpha ne and &beta eq %then %do;
%let beta=α
%end;
%put &alpha β
%mend;
%test()
try this one:
%macro test(alpha,beta);
%if &alpha eq and &beta eq %then %do;
%let alpha=0.005;
%let beta=0.005;
%end;
%if &alpha ne and &beta eq %then %do;
%let beta=α
%end;
%put &alpha β
%mend;
%test()
The Problem is in statement
%let &beta=α
your are assigning the value of alpha to value of beta.the correct statement should be
%let beta=α
where you assign the value of alpha to macro variable beta.
There is a hole in your logic. What should the value of BETA be when only ALPHA is specified?
Assuming you want it to be 0.005 then the logic simplifies to this:
%if &beta = %then %let beta=0.005;
%if &alpha = %then %let alpha=β
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.