DATA Step, Macro, Functions and more

SAS reporting: group data

Frequent Contributor
Posts: 127

SAS reporting: group data

[ Edited ]

Dear experts,


I have data set (sheet input in the attachment) and on the base of two variables, seller id and revenues, I wouldlike to group the data showing:

- top 5 sellers;

- residual part;

- absolute and percentage values;

(sheet output in the attachment).

I just used the proc sql to sort and then I selected the top 5 using the outobs in the proc sql but to get the full picure I want is taking too many steps. Any elegant and wuick solution to propose?

Thanks in advance.





Super User
Posts: 5,260

Re: SAS reporting: group data

How many is too many?
PROC RANK is an alternative to pick a top.
For the percentage (and the overall report) I would investigate if PROC TABULATE could fit your needs.

Please don't attach Excel files.
Data never sleeps
Super User
Posts: 10,538

Re: SAS reporting: group data

This link has instructions on how to turn a SAS dataset into a datastep. Then you can post text of the actual data (or your example data at least) in form that we can use to test code.


Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

Frequent Contributor
Posts: 127

Re: SAS reporting: group data

Thanks for you advises, I cheked the proc rank but in the end I got what I needed using the dear old proc sql and a proc tabulate to finalize it.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation