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