BookmarkSubscribeRSS Feed
gamotte
Rhodochrosite | Level 12

Hi,

I have a stored process (SP) which contains the following proc sql

proc sql;

SELECT NAME

FROM a.TABLE

WHERE NAME NOT IN (&cond);

quit;

&cond is dynamically determined by the calling SP and passed

through the URL :

SASStoredProcess/do?_program=/BIP Tree/ReportStudio/StoredProcesses/my_sp&cond="NAME1" "NAME2"

The above sql procedure is not executed because of a syntax error

ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, -.

However the log indicates that the macrovariable cond generates "NAME1" "NAME2" as wished.

Moreover, when I copy/paste the resolved proc sql displayed in the log in SAS and execute it, it works.

proc sql;

SELECT NAME FROM a.TABLE WHERE NAME NOT IN ("NAME1" "NAME2");

quit;

How can I get this proc to work ?

Thanks

2 REPLIES 2
Amir
PROC Star

Hi,

Just a guess, is it worth trying to use the %unquote() function, e.g.:

WHERE NAME NOT IN (%unquote(&cond))

Regards,

Amir.

gamotte
Rhodochrosite | Level 12

Thanks ! You guessed right. It works.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 933 views
  • 0 likes
  • 2 in conversation