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;
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;
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 179Total 4784
proc summary data=want nway missing;
by ethnicity;
output out=test (drop=_type_ rename=(_freq_ = number));
run;
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;
Because you have only one by/class variable removing "nway" and adding "descendtypes" from/to the proc summary statement.
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;
Remove NWAY and use
class ethnicity;
instead of
by ethnicity;
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!
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.