Hello,
I'm curious how to get the percent for the total amount of in the 'Charge' column. Thanks.
data dataIN;
infile datalines dsd;
input PT_class : $50. Charge;
datalines;
ICU, 100,
Lab, 200,
Radiology, 300,
PF fee, 500,
;
ANY time you discuss percent, or other rates for that matter, you need to define what value is used for the numerator and what value is used for the denominator.
So since I don't see anything clearly labeled as "total charge" I have no confidence what a percentage would be with that data.
And do you want a data set, for further manipulation, or a report, for people to see?
A report might be:
proc tabulate data=datain; var charge; class pt_class; table pt_class, charge*pctsum ; run;
proc sql;
create table want as select
pt_class
,charge
,100*charge/sum(charge) as percent
from datain;
quit;
ANY time you discuss percent, or other rates for that matter, you need to define what value is used for the numerator and what value is used for the denominator.
So since I don't see anything clearly labeled as "total charge" I have no confidence what a percentage would be with that data.
And do you want a data set, for further manipulation, or a report, for people to see?
A report might be:
proc tabulate data=datain; var charge; class pt_class; table pt_class, charge*pctsum ; run;
how about this code?
proc sql;
create table want as
select PT_class, Charge, round(charge/sum(Charge)*100,0.01) as perc
from dataIN
;
quit;
Alternative solution:
proc freq data=datain;
tables pt_class/out=want noprint;
weight charge;
run;
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.