BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MikeTurner
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

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

manojinpec
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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