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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 1345 views
  • 2 likes
  • 6 in conversation