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=β
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.