BookmarkSubscribeRSS Feed
MPaola
Calcite | Level 5
With a PROC REPORT is it possibile to put in output only those rows with a column value > x?

Example
Complete report:
GroupVariable_A |__B_|__C_|
aaaa __________|1000|2000|
bbbb __________|___0|___1|
cccc __________|5000|3000|

Desidered report (only rows with B >= 1000)
GroupVariable_A |__B_|__C_|
aaaa __________|1000|2000|
cccc __________|5000|3000|

Thanks
MPaola
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
It depends.

If B is based on a single observation, where GroupVariableA has been defined as a DISPLAY or ORDER variable, then a simple WHERE clause will eliminate the rows where _B is LT 1000 or GT X. However, if B is summarized based on your GroupVariable_A actually being defined with a usage of GROUP in PROC REPORT, then you will need to "pre-summarize" your data to determine which rows should "go forward" to PROC REPORT. There have been some previous postings on the subject, but it will be simple enough to do -- just use PROC MEANS, PROC SQL, PROC TABULATE and/or PROC REPORT to get summarized values and then eliminate the summarized rows that do not conform to what you want.

This does mean making 2 passes through the data. Just remember that any grand totals will not include those variables' values, if you eliminate the rows from the summary data -- unless you work on getting the numbers back in the total.

cynthia
Ksharp
Super User
And compute block will also can help you.


Ksharp
Ksharp
Super User
And compute block will also can help you.


Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 712 views
  • 0 likes
  • 3 in conversation