DATA Step, Macro, Functions and more

what's wrong with this macro?

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

what's wrong with this macro?

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()


Accepted Solutions
Solution
‎03-29-2012 12:17 AM
Super Contributor
Posts: 1,636

what's wrong with this macro?

Posted in reply to MikeTurner

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()

View solution in original post


All Replies
Solution
‎03-29-2012 12:17 AM
Super Contributor
Posts: 1,636

what's wrong with this macro?

Posted in reply to MikeTurner

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()

Frequent Contributor
Posts: 139

what's wrong with this macro?

Posted in reply to MikeTurner

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.

Super User
Super User
Posts: 7,079

Re: what's wrong with this macro?

Posted in reply to MikeTurner

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=β

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 251 views
  • 6 likes
  • 4 in conversation