BookmarkSubscribeRSS Feed
Gary_Z
Fluorite | Level 6

I'm trying to understand how the whereTable paramater in CAS actions works in detail. 

Why would the whereTable parameter be used instead of using the WHERE expression? what are the possible limitations of using the whereTable parameter and how does it operate specifically? There isn't detailed information about whereTable in the Help center documentation.

1 REPLY 1
DerylHollick
SAS Employee

It's a way to filter rows of a table based on values of like variables in another table.

 

data casuser.baseball;
   set sashelp.baseball;
run;

data casuser.where_table1;
   set sashelp.baseball;
   where team='Montreal';
   keep team Name;
run;

data casuser.where_table2;
   set sashelp.baseball;
   where nhits >= 100;
   keep name team nhits;
run;

proc cas;
table.copyTable /                         
    casout={caslib="casuser", name="baseball_montreal", replace=TRUE},
    table={caslib="casuser", name="baseball", whereTable={caslib="casuser" name="where_table1"}};

table.copyTable /                         
    casout={caslib="casuser", name="baseball_nhits", replace=TRUE},
    table={caslib="casuser", name="baseball", whereTable={caslib="casuser" name="where_table2"}};

table.fetch / table="baseball_montreal"; 
table.fetch / table="baseball_nhits"; 
quit;

 

You're right, though, the doc is light on the details, but I did find this one example with some explanation:

SAS Help Center: Filter Multiple Input Tables Based on Values in a whereTable

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 529 views
  • 1 like
  • 2 in conversation