DATA Step, Macro, Functions and more

use macro in if-else statement

Accepted Solution Solved
Reply
Contributor
Posts: 47
Accepted Solution

use macro in if-else statement

when I merely used macro:

 

%extracTable();

 

there is no error..

 

however when I am using :

data _null_;

if 1=1

then %extracTable();

else put @@@do not insert@@@;

run;

 

it return :

error:unquote array:Execute

error:388-105

error 76-322

error:180-322

 

why and how to fix it...I am weak at sas Marco grammar..thank you


Accepted Solutions
Solution
‎03-21-2018 02:06 AM
Super User
Posts: 6,933

Re: use macro in if-else statement

My preference is to just let it stand as is.  I say that because the question has changed somewhat.  One of my pet peeves is questions that morph as they are solved, and I would much rather avoid that.  

 

"OK, that worked but what I really need is to ..."

 

"OK, that worked.  The next step is to ..."

 

Let this part stand as a separate question, and chips fall where they may.

View solution in original post


All Replies
Super User
Posts: 2,512

Re: use macro in if-else statement

Try:

if 1=1 then call execute('%extracTable();');

Contributor
Posts: 47

Re: use macro in if-else statement

thanks..I get the result right,but still an error :
ERROR 180-322:statement is not valid.
why and how to do..
Super User
Posts: 6,933

Re: use macro in if-else statement

I'm not sure I should reply.  You seem unwilling or perhaps unable to take my advice on other questions.  So last attempt:

 

data _null_;

if 1=1

then call execute('%nrstr(%extracTable())');

else put '@@@do not insert@@@';

run;

 

It's not clear why you need an ELSE condition when 1=1 must always be true, but perhaps this is a simplification of a more complex problem.

Super User
Posts: 2,512

Re: use macro in if-else statement

Posted in reply to Astounding

@Astounding I didn't see this thread was the continuation of another thread.

Maybe should it be marked as spam to remove duplicates?

Solution
‎03-21-2018 02:06 AM
Super User
Posts: 6,933

Re: use macro in if-else statement

My preference is to just let it stand as is.  I say that because the question has changed somewhat.  One of my pet peeves is questions that morph as they are solved, and I would much rather avoid that.  

 

"OK, that worked but what I really need is to ..."

 

"OK, that worked.  The next step is to ..."

 

Let this part stand as a separate question, and chips fall where they may.

Contributor
Posts: 47

Re: use macro in if-else statement

Posted in reply to Astounding
thanks in advance..I get the result right,but still an error :
ERROR 180-322:statement is not valid.
why and how to do..
Super User
Posts: 6,933

Re: use macro in if-else statement

For someone to diagnose the error, you will need to post the log. 

Super User
Posts: 13,941

Re: use macro in if-else statement

Posted in reply to Astounding

@Astounding wrote:

For someone to diagnose the error, you will need to post the log. 


And perhaps the actual macro code that is called.

 

And run the code with: Options mprint symbolgen mlogic;

 

Then post the log with the code and error messages into a code box opened using the forum {I} menu icon. Error messages often have indicators of position where SAS identified the error but the main message windows of this forum will reformat text resulting in moved indicators. The code box will preserve text as copied from the log so the diagnostics are in the correct position.

 

Note that errors caused by macro code do not display in the most helpful manner unless the MPRINT option is set. 

☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 176 views
  • 0 likes
  • 4 in conversation