Solved
Contributor
Posts: 34

# PROC TABULATE - Order by analysis variable?

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 :-)

Accepted Solutions
Solution
‎01-16-2012 04:54 PM
SAS Super FREQ
Posts: 9,367

## PROC TABULATE - Order by analysis variable?

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

All Replies
Solution
‎01-16-2012 04:54 PM
SAS Super FREQ
Posts: 9,367

## PROC TABULATE - Order by analysis variable?

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

Contributor
Posts: 34

## PROC TABULATE - Order by analysis variable?

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 ;-)