09-27-2016 12:49 AM
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.
09-27-2016 03:30 AM
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.
09-27-2016 04:52 AM
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:
09-28-2016 10:41 AM
09-28-2016 07:14 PM
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.
09-29-2016 04:48 AM
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.
09-29-2016 05:48 PM
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.