BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9
data groups;
set cert.input48;
if upcase(cvar) in ('A','B','C','D','E','F','G') then group=1;
else if upcase(cvar) in ('H','I','J','K','L','M','N') then group=2;
else group=3;
numy=input(y,10.);
run;
proc means data=groups mean maxdec=0;
var numy;
where group=2;
run;

where group=2  , why is not using 'if' ? 

1 ACCEPTED SOLUTION

Accepted Solutions
maguiremq
SAS Super FREQ

You can't use IF to subset your dataset within PROC MEANS. You can only use WHERE.

 

In DATA steps, using WHERE on the SET statement usually allows for faster processing by only reading in observations that fit the condition. Using IF requires reading in all observations and then subsetting based on that condition.

View solution in original post

4 REPLIES 4
maguiremq
SAS Super FREQ

You can't use IF to subset your dataset within PROC MEANS. You can only use WHERE.

 

In DATA steps, using WHERE on the SET statement usually allows for faster processing by only reading in observations that fit the condition. Using IF requires reading in all observations and then subsetting based on that condition.

tarheel13
Rhodochrosite | Level 12

You can only use if in data step. Proc, you have to use where statement.

ballardw
Super User

@tarheel13 wrote:

You can only use if in data step. Proc, you have to use where statement.


I might modify that "only use IF to subset data in a data step".

A few procedures have places where "IF" is used for things other than subsetting data.

tianerhu
Pyrite | Level 9

Thank you for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1003 views
  • 1 like
  • 4 in conversation