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;
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!
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.
Ready to level-up your skills? Choose your own adventure.