BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I have a variable x. Now I want to select some of the observations. I want to start with 10units above the minimum and end at minimum plus 30units.
but it doesnt work when I use
where x between min(x+10) and min(x+30);
The min Function take only singlenumbers limitetd by comma.

Have anybody an idea to solve this problem?

Thanks
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You are correct - the WHERE statement (as the same with the IF stmt) will only interrogate the current observation. You need to use PROC SUMMARY/MEANS to generate a file containing the MIN and MAX as new variables, and then one option is to MERGE the resulting file back into your SAS file - then you have the MIN and MAX value range (again, as unique SAS variables created in the MEANS/SUMMARY step) to use in your WHERE statement.

Scott Barry
SBBWorks, Inc.
FredrikE
Rhodochrosite | Level 12
It might not be the beautiest of solutions, but works with smaller datasets:

Proc sql;
select *
from sashelp.class
where age between
(select min(age) + 2 from sashelp.class)
and
(select max(age) - 2 from sashelp.class)
;
quit;

//Fredrik
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
  • 2 replies
  • 1163 views
  • 0 likes
  • 3 in conversation