Reputation: 1
I am a beginner of SAS language learning. I learn that there are five Special_where operators we use in SAS. Among them one is WHERE SAME AND operator. Could anyone help me how will I use that operator with an example
Thanks in Advance
Upvotes: 0
Views: 1958
Reputation: 51566
You can use WHERE
statement in DATA steps and also probably more usefully in PROC steps. The WHERE SAME AND
which also perhaps easier to remember under it's other name of WHERE ALSO
will let you use multiple statements to add more restrictions.
This is easy to see with an example like:
proc means data=sashelp.class ;
where sex='M';
where also age > 12 ;
var height;
run;
because SAS will echo the resulting subsetting condition to the LOG.
1334 proc means data=sashelp.class ;
1335 where sex='M';
1336 where also age > 12 ;
NOTE: WHERE clause has been augmented.
1337 var height;
1338 run;
NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 6 observations read from the data set SASHELP.CLASS.
WHERE (sex='M') and (age>12);
Note that is you use both WHERE
and WHERE ALSO
statements the order makes a difference.
1339 proc means data=sashelp.class ;
1340 where also age > 12 ;
NOTE: WHERE clause has been augmented.
1341 where sex='M';
NOTE: WHERE clause has been replaced.
1342 var height;
1343 run;
NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 10 observations read from the data set SASHELP.CLASS.
WHERE sex='M';
But you can always just use WHERE ALSO
for all of the statements and then the order doesn't matter.
1344 proc means data=sashelp.class ;
1345 where also age > 12 ;
NOTE: WHERE clause has been augmented.
1346 where also sex='M';
NOTE: WHERE clause has been augmented.
1347 var height;
1348 run;
NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 6 observations read from the data set SASHELP.CLASS.
WHERE (age>12) and (sex='M');
Upvotes: 4