BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
f_rederik
Obsidian | Level 7

I'm trying to build a Summary Table using PROC TABULATE, but I would like to order the table not by the class variable, but the measure.

Enterprise Guide got me started with the following code, but I'm struggling to find out how I can sort the table by the variable SUM_of_Saldo (rather than the SSB_Navn)

PROC TABULATE

DATA=WORK.QUERY_FOR_BSU_RK_TIMESNAP_0009

  FORMAT=commax32.;

          VAR SUM_of_Saldo ;

          CLASS Periode /          ORDER=UNFORMATTED MISSING;

          CLASS SSB_Navn /          ORDER=UNFORMATTED MISSING;

  TABLE

/* ROW Statement */

                    SSB_Navn

                    all = 'Total'  ,

 

/* COLUMN Statement */

                    Periode *(SUM_of_Saldo * Sum={LABEL="Sum"} )

                    all = 'Total'  *(SUM_of_Saldo * Sum={LABEL="Sum"} )                     ;

          ;

RUN;

Thanks for any pointers 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  This is a similar post and the answer is the same. It is easier to do what you want with PROC REPORT than with PROC TABULATE. The screenshot attached to this posting shows the type of code to use with PROC REPORT.

http://communities.sas.com/message/100730/#100730

  The bottom line is that neither TABULATE nor REPORT will allow you to order on the equivalent of a statistic or calculated analysis variable. But if you create an ordering variable, then you can force PROC REPORT to show the data using the calculated amount (as shown in the screen shot where value C with a total of 15 is listed first).

cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
Diamond | Level 26

Hi:

  This is a similar post and the answer is the same. It is easier to do what you want with PROC REPORT than with PROC TABULATE. The screenshot attached to this posting shows the type of code to use with PROC REPORT.

http://communities.sas.com/message/100730/#100730

  The bottom line is that neither TABULATE nor REPORT will allow you to order on the equivalent of a statistic or calculated analysis variable. But if you create an ordering variable, then you can force PROC REPORT to show the data using the calculated amount (as shown in the screen shot where value C with a total of 15 is listed first).

cynthia

f_rederik
Obsidian | Level 7

Thanks Cynthia

I know I should probably spend some more time getting to grips with the code, but I seem to always manage somehow using Enterprise Guide...

Seems EG does not have a built in task for PROC REPORT, so just need to get my old coding fingers dirty 😉

Thanks for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4023 views
  • 1 like
  • 2 in conversation