BookmarkSubscribeRSS Feed
aloou
Obsidian | Level 7

Hello everyone,

i am having a problem with this proc cas , the where statement is not accepted and gets me an error.

do you have ideas ?

 

thanks

 

proc cas;
table.deleterows /
table={name="TEST" caslib="mine" where='ID in (select id from triangle)'};
run;

2 REPLIES 2
ballardw
Super User

"Not accepted" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.

Kurt_Bremser
Super User

I do not think you can use a SQL subselect for the IN operator there.

 

The ERROR message should look like this:

ERROR: Syntax error detected on line 2 at column 10.  Found SELECT, expecting a quoted string, a numeric constant, a datetime 
       constant, a missing value, -.  

which means you must supply a list of literals.

Use PROC SQL to store the results into a macro variable for use in the WHERE, like

proc sql noprint;
select distinct quote(trim(id),"'") into :id_list separated by ","
from triangle;
quit;

and then do

table.deleterows / 
table={name="TEST" caslib="mine" where="ID in (&id_list.)"};

Disclaimer: I have yet to start with Viya/CAS, but from a few quick tries I arrived at this suggestion. Have no idea if it works.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 514 views
  • 3 likes
  • 3 in conversation