BookmarkSubscribeRSS Feed
jitinsethi07
Obsidian | Level 7

I am getting this error: Syntax error while parsing WHERE clause.

while running the below code, kindly help:

%macro abc;

data null;
set newdata;
%Do %until(100);
call symput ('SLP', SLP);
call execute
(
'proc imstat' || ' data = ' || ' LASRLIB.scans ' || ';' ||
'where ' || put(SCANDATE, date7.) || '=' || "07FEB19" || ';' ||
' run; ' ||
' deleterows / purge ;' ||
' run;'
);

%end;

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, your problem lies in:

put(SCANDATE, date7.) = 

When scandate is put into text, there will be a numeric as first character, this is not valid in SAS.  Maybe you mean:

'where "' || put(SCANDATE, date7.) || '"=' || "07FEB19" || ';' ||

 

Although I really don't see why you have that code at all, there really is a better way than creating SLP macro variable and generating the proc imstat code 100 times - which is all that code is doing, there is nothing changing in the code as far as I can see any of the 100 iterations.  So does not make sense in any way.

 

Astounding
PROC Star

As a secondary issue, there is nothing about this %DO loop that causes it to execute 100 times.  It executes once per observation in NEWDATA.  

 

It's difficult to determine what you intended here by adding the %DO loop.  Perhaps:

 

set newdata (obs=100);

 

Finally, note the possibility to simplify by combining a few character strings:

 

'="07FEB19"; run;'

 

In fact, your intention may have been to combine more than that:

 

'proc imstat data=LASRLIB.scans; where put(SCANDATE, date7.)="07FEB19"; run;'

 

Some issues are not clear ... where did you intend to use &SLP?  Where does SCANDATE come from?

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!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 5003 views
  • 0 likes
  • 3 in conversation