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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1336 views
  • 0 likes
  • 3 in conversation