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

I have a simple code that creates this output but I need the total. Is there a way to get that added?

 

Ethnicity Clients
A 2822
B 929
C 383
D 471
E 179

Total 4784

 

proc summary data=want nway missing;
by ethnicity;
output out=test (drop=_type_ rename=(_freq_ = number));
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
proc sql;
create table want as
select bp_status length=40,count(*) as clients
 from sashelp.heart
  group by bp_status
union all
select 'Total',count(*) from sashelp.heart
;
quit;

View solution in original post

5 REPLIES 5
Reeza
Super User

Remove the NWAY and filter the results using the _TYPE_ column.
_TYPE_ = 0 is the total.

 


@ywon111 wrote:

I have a simple code that creates this output but I need the total. Is there a way to get that added?

 

Ethnicity Clients
A 2822
B 929
C 383
D 471
E 179

Total 4784

 

proc summary data=want nway missing;
by ethnicity;
output out=test (drop=_type_ rename=(_freq_ = number));
run;




Kurt_Bremser
Super User

An example using PROC REPORT off SASHELP.CARS:

proc report data=sashelp.cars;
column origin n;
define origin / group;
define n / "Number";
rbreak after / summarize;
compute after;
  origin = "Total";
endcomp;
run;
andreas_lds
Jade | Level 19

Because you have only one by/class variable removing "nway" and adding "descendtypes" from/to the proc summary statement.

 

Ksharp
Super User
proc sql;
create table want as
select bp_status length=40,count(*) as clients
 from sashelp.heart
  group by bp_status
union all
select 'Total',count(*) from sashelp.heart
;
quit;
PaigeMiller
Diamond | Level 26

Remove NWAY and use 

 

class ethnicity;

instead of 

 

by ethnicity;
--
Paige Miller

hackathon24-white-horiz.png

Join the 2025 SAS Hackathon!

Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 2686 views
  • 2 likes
  • 6 in conversation