BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data test;

infile datalines;

input ctr $ cnt ;

return;

datalines;

4411 5

4455 15

4466 6

4477 11

;

run;

 

proc report = test style(summary)=Header;

title 'test';

column ctr cnt PctTot;

define ctr /order order=data style (column)=Header;

define cnt /sum f=comma6.;

define PctTot ?????????????

compute after ctr ;

line ' ';

endcomp;

run;

 

I am attempting to do the following:

 

Desired Output

Title ‘ test’

Ctr                         Cnt                 PctTot

4411                      5                   13.51%     

4455                      15                 40.54%   

4466                       6                  16.21%

4477                       11                 29.72%   

Grand Total            37                100.00

 

I need to round the PctTot   2 decimal places and include lines as well as a Grand Total

3 REPLIES 3
Ksharp
Super User
How about this one.


data test;
infile datalines;
input ctr $ cnt ;
return;
datalines;
4411 5
4455 15
4466 6
4477 11
;
run;
 

proc report data= test nowd style(summary)=Header;
title 'test';
column ctr cnt PctTot;
define ctr /order order=data style (column)=Header ;
define cnt /sum f=comma6.;
define PctTot/computed f=percent8.2;
compute before;
 sum=cnt.sum;
endcomp;
compute PctTot;
 pcttot=cnt.sum/sum;
endcomp;
compute after;
 ctr='Total';
endcomp;
rbreak after /summarize;
run;
 


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 660 views
  • 1 like
  • 3 in conversation