The SAS Output Delivery System and reporting techniques

Proc Report with selected rows

Reply
Occasional Contributor
Posts: 9

Proc Report with selected rows

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
SAS Super FREQ
Posts: 8,740

Re: Proc Report with selected rows

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
Super User
Posts: 9,662

Re: Proc Report with selected rows

And compute block will also can help you.


Ksharp
Super User
Posts: 9,662

Re: Proc Report with selected rows

And compute block will also can help you.


Ksharp
Ask a Question
Discussion stats
  • 3 replies
  • 139 views
  • 0 likes
  • 3 in conversation