BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AZIQ1
Quartz | Level 8

Hi,

I am trying to run proc freq on a charachter variable with multiple where statement eg.plus additional criteria,

 

where var = "1" or var = "2" or var="3",

where var2 = 1;

 

its not working? does not give errors but just a

NOTE: WHERE clause has been replaced.

any suggestions as to why this is not working?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Additionally there are bits that can make your clauses shorter and perhaps easer to understand.

One is use of the IN operator to check for a list of conditions on a single variable:

 

Where Var in ('1' '2' '3') ;

if the values are numeric you can use a range of values:

 

Where Var2 in (1 3 15:27); matches 1, 3 and everything from 15 to 27 inclusive.

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

The second WHERE statement is replacing the first. Instead of using two WHERE clauses, use a single statement.  I'm not sure if you want AND or OR, but try like:

 

where (var = "1" or var = "2" or var="3") AND

           var2 = 1;

 

FreelanceReinh
Jade | Level 19

Hi @AZIQ1,

 

Maybe you were thinking of the "NOTE: WHERE clause has been augmented."? This (comparably harmless) note occurs if a WHERE statement and a WHERE= dataset option are used in conjunction. Example:

 

proc freq data=sashelp.class(where=(age>14));
where weight>100;
tables age;
run;

 

ballardw
Super User

Additionally there are bits that can make your clauses shorter and perhaps easer to understand.

One is use of the IN operator to check for a list of conditions on a single variable:

 

Where Var in ('1' '2' '3') ;

if the values are numeric you can use a range of values:

 

Where Var2 in (1 3 15:27); matches 1, 3 and everything from 15 to 27 inclusive.

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 59622 views
  • 2 likes
  • 4 in conversation