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);
I tried the codes on my colleague's computer and it worked fine. But not on my computer. It's so weird.
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
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.
It is so weird .Did you open a new sas session ? What is your log ?
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);
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
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.