BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

data _null_;

if 1=1 then

call execute('%extractTable();');

call execute('%scoreUpdate()');

call execute('%writeTable();');

call execute(

       'proc sql noprint;

           insert into tableA(date,tag)

            set date=today(),

             tag=1;');

else call execute('%writeIndex();');

run;

 

return Error 160-185:no match if-then statement

 

the problem is caused  calling execute multiple macros..please fix the sas codes..thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

One version:

 

data _null_;

if 1=1 then

call execute

        ('  %nrstr( %extractTable() %scoreUpdate() %writeTable() )

            proc sql noprint;

            insert into tableA(date,tag)

            set date=today(),

             tag=1;

       ');

else call execute('%nrstr(%writeIndex())');

run;

 

It's possible that adding %NRSTR is overkill and unnecessary.  But there's no way to know without seeing the contents of the four macros.

 

Consider whether a QUIT statement should be added at the end of PROC SQL.

View solution in original post

4 REPLIES 4
gamotte
Rhodochrosite | Level 12
Hello,

Since you are not reading values from an input dataset, there is no need here for a data step with call execute instructions. You can directly call your macros :

%extractTable();
%scoreUpdate()
...
gamotte
Rhodochrosite | Level 12

As for the error you mentionned, if several instructions have to be executed when a given condition is met, they have to be enclosed by do;...end;

 

if (<condition>)  then do;

  <instruction1>

  <instruction2>

  ...

end;

Astounding
PROC Star

One version:

 

data _null_;

if 1=1 then

call execute

        ('  %nrstr( %extractTable() %scoreUpdate() %writeTable() )

            proc sql noprint;

            insert into tableA(date,tag)

            set date=today(),

             tag=1;

       ');

else call execute('%nrstr(%writeIndex())');

run;

 

It's possible that adding %NRSTR is overkill and unnecessary.  But there's no way to know without seeing the contents of the four macros.

 

Consider whether a QUIT statement should be added at the end of PROC SQL.

Kurt_Bremser
Super User

The use of %nrstr depends on the contents of the macros. If they only have macro variables/parameters used, %nrstr is not needed. But if there's logic in there (%if %then %else), or steps that create macro variables for later use, you can get into timing problems, as macro statements will be executed as soon as they are pushed onto the execution stack, while data or proc steps cannot run before the current data step finishes.

%nrstr prevents such premature resolution of macros.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 2334 views
  • 1 like
  • 4 in conversation