Hello SAS experts,
I am trying to produce a report where I generate columns using an ACROSS variable with a calculated total. Ideally, each row of the report would then be sorted descending by the calculated total. I am having trouble getting this to work as expected, and am thinking it might not be possible. Is there a way to get PROC REPORT to sort by a calculated total variable by groups using ACROSS? When I add ORDER to the DEFINE TOT statement, I get a stairstepping report, which I do not want.
The code below produces an example of the un-sorted report. The report I am looking to generate is exactly this, except I am trying to sort the "Total" column descending by Subsidiary. If this were a PROC SORT the equivalent sort I'd be looking for is:
BY Region descending tot;
Before I resort to pre-processing the data and then generating the report, I wanted to see if it was indeed not possible to sort in this manner.proc report data=sashelp.shoes nowd spanrows; where Region in ('Africa' 'Asia'); column ("Summary of Shoes" (Region Subsidiary) (Sales,Product Sales=tot)); define Region / '' group noprint; define Subsidiary / 'Subsidiary' group; define Product / across; define Sales / analysis mean ''; define tot / analysis sum 'Total'; compute before Region / style=[just=l font_style=italic font_weight=bold background=Lightblue foreground=black]; if Region="Africa" then do; text="Africa Region"; end; if Region="Asia" then do; text="Asia Region"; end; line text $50.; endcomp; run;
Thanks in advance!
Got it, thank you Cynthia! I will give this a shot.
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.