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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2464 views
  • 2 likes
  • 4 in conversation