BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I want to print in proc report only rows with BMI between 19 and 21

What  is the way to do it?

proc report data=sashelp.class nowd;  
column name weight height BMI; 
define name / display; 
define weight / display; 
define height / display;
define bmi / computed format=4.1 'BMI';  
compute bmi;    
bmi = weight/(height*height)*703;
endcomp;  
run;

 

 

 

6 REPLIES 6
Kurt_Bremser
Super User

Apply the same formula in a WHERE= dataset option or a WHERE statement.

proc report
  data=sashelp.class (where=(19 le weight/(height*height)*703 le 21))
  nowd
;

 

Ronein
Onyx | Level 15

Thanks,

Is there a way to perform it with related to the computed column ?

In complicated cases the  computed column is not simple calculation and then it will be difficult to apply it in such way 

Ronein
Onyx | Level 15
How can I ask her?
Cynthia_sas
Diamond | Level 26
Hi:
Unfortunately, PROC REPORT will not do what you want to do. When you are computing a column, the report row is already built and the other columns populated, so you're asking PROC REPORT to both build the report row and then suppress the same report row based on the value of the computed column.
@Kurt_Bremser's solution to use a WHERE or to pre-process the data in a DATA step before the PROC REPORT step are the only solutions in this case.
Cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 1871 views
  • 0 likes
  • 3 in conversation