BookmarkSubscribeRSS Feed
MikeTurner
Calcite | Level 5

I wrote the macro indd and I'm wondering why the macro can't be resolved when I call the macro by: %put  i'm running %indd(no).

Is there something wrong with the macro? Thanks in advance.

%macro indd(in);

%if %upcase(&in)=YES %THEN %do;

%end;

%else %do;

noint

%end;

%mend;

%put  i'm running %indd(no);

7 REPLIES 7
MikeTurner
Calcite | Level 5

I tried the codes on my colleague's computer and it worked fine. But not on my computer. It's so weird.

Ksharp
Super User

Due to this special single quote :  i'm running

%macro indd(in);

%if %upcase(&in)=YES %THEN %do;

 yes

%end;

%else %do;

noint

%end;

%mend;

option mprint symbolgen mlogic; 

%put  %str(i%'m running) %indd(no) ;

Ksharp

MikeTurner
Calcite | Level 5

Thank you, Ksharp.

I tried your codes and still didn't work. I suspected something wrong with my computer's setting.

I tried your codes and my codes on my colleague's computer and all worked fine.

Thanks. 

Ksharp
Super User

It is so weird .Did you open a new sas session ? What is your log ?

MikeTurner
Calcite | Level 5

I opened a new sas session. It seemed that the codes sometimes worked fine and sometimes not.  Please have a look at the log. Thank all.

16   %macro indd(in);

17   %if %upcase(&in)=YES %THEN %do;

18

19   %end;

20   %else %do;

21   noint

22   %end;

23   %mend;

15   %put  i'm running %indd(no);

            ---------------------

            49

NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS

             release.  Inserting white space between a quoted string and the succeeding

             identifier is recommended.

24   option mprint symbolgen mlogic;

25   %put  i'm running %indd(no);

MLOGIC(INDD):  Beginning execution.

MLOGIC(INDD):  Parameter IN has value no

SYMBOLGEN:  Macro variable IN resolves to no

MLOGIC(INDD):  %IF condition %upcase(&in)=YES is FALSE

MLOGIC(INDD):  Ending execution.

i'm running %indd(no);%macro indd(in);%if %upcase(&in)=YES %THEN %do;%end;%else

%do;noint%end;%mend;option mprint symbolgen mlogic;%put  i'm running noint

26   %put  i'm running %indd(no);

DanielSantos
Barite | Level 11

OK, I got it.

Code tested was actually the one Ksharp posted, which runs fine.

It's the ' char inside the %put

It's totally messing the compiler, that's why you get erratic runs.

As Ksharp suggested, enclose it inside a masking macro functions so the compiler can get the code right.

%str(%')

More on masking here:

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001061345.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

DanielSantos
Barite | Level 11

Runs fine. Nothing wrong about your code.

Please share the log and context of your session.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 7 replies
  • 2222 views
  • 0 likes
  • 3 in conversation