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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2698 views
  • 2 likes
  • 6 in conversation