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=β
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.