Hi,
First time using PROC REPORT and I have not understanding the sort order.
Under PROC SQL it is something like:
select * from table1 order by colX asc, colY desc
In PROC REPORT, I guess you use
define colX / display order order=data ;
define colY / display order order=data descending ;
I have two questions:
How do you asign an overall order to the definition? ie, I need it order by colX first and then colY
How do I include display data with null values in the order column? Once you put the word order in the define line, the row no longer appears in the output.
Many thanks
Mark
Hi Mark,
You could first of all, do a proc sort by colX and ColY. After that, you could create a new variable order=_N_.
Doing this you create a non missing variable to order data. adding to columns this variable and a definition like
define Order /noprint order
you should see your data as you want.
The order of the columns is defined by the columns statement:
proc report...; column var1 var2; define var1 / order; define var2 / order; run;
In this example the data is sorted by var1 and then var2, you would swap them over by changing the position in the column. Per the documentation. Here is an example:
http://support.sas.com/resources/papers/proceedings11/090-2011.pdf
Hi,
Thank you all for your help.
What I was trying to do was to format a pdf output. I was looping though multiple clients and creating five subtables for each client. Each pdf report ran up to 4000 pages.
I ended up using proc sql instead. It is much easier to write and once I realised you could give a different class to each table, the pdf now looks very colourful and easy to read.
Cheers
Mark
In which case by group processing is what you want:
proc report data=...; by client subgroup; title1 "Client=#byval1"; title2 "Subgroup=#byval2"; ... run;
Does all that looping for you. Only time I loop myself is if there are complicated by groupings and such like.
Thank you for your reply. I have not used the approach you mentioned, is it possible to write a little more pseudo code for me?
At the moment I am using a macro to loop through the clients
Then I draw data from five separate tables for each client – move to the next client, etc.
The recipients of the report insist each of the five tables have a different format (colour, font) so it is easier for them to delineate.
The whole report ends up as a large pdf.
Cheers
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.