BookmarkSubscribeRSS Feed
MathJack901015
Calcite | Level 5

Hello, I'm bit new in SAS. I have a dataset made via a proc report like this one:

 

Central         Generation

 

Central1        394

Central2        8384

Central3        384

Total H          (sum)

Central4        2342

Central5        2321

Total T           (sum)

Total Agent   (total sum)

 

What I want is change the position of the 'Total' rows to the beggining of each block. The original dataset has 52 of these blocks, I mean, somethig like this

 

Central         Generation

 

Total Agent   (total sum)

Total H          (sum)

Central1        394

Central2        8384

Central3        384

Total T           (sum)

Central4        2342

Central5        2321

 

Is there any way to perform this? Thanks in advance.

3 REPLIES 3
Reeza
Super User
Not easily. Add another variable that contains your sort order which has to be somewhat manual and then sort it. In general, this is why there's a recommendation to not store totals and subtotals in data sets but calculate them in reporting procedures such as PROC REPORT.
ballardw
Super User

@MathJack901015 wrote:

Hello, I'm bit new in SAS. I have a dataset made via a proc report like this one:

 

Central         Generation

 

Central1        394

Central2        8384

Central3        384

Total H          (sum)

Central4        2342

Central5        2321

Total T           (sum)

Total Agent   (total sum)

 

What I want is change the position of the 'Total' rows to the beggining of each block. The original dataset has 52 of these blocks, I mean, somethig like this

 

Central         Generation

 

Total Agent   (total sum)

Total H          (sum)

Central1        394

Central2        8384

Central3        384

Total T           (sum)

Central4        2342

Central5        2321

 

Is there any way to perform this? Thanks in advance.


You might be able to do the "report" with proc tabulate as that allows group totals to come first.

proc tabulate data=sashelp.class;
   class age sex;
   table all='Overall Count' ( age='')*(all='Age Count' sex=''),
         n;
run;

Proc tabulate also creates output data sets but working with them may be a tad daunting.

 

Ksharp
Super User

Use

break before cental/summarize;

rbreak before cental/summarize;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 2801 views
  • 2 likes
  • 4 in conversation