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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.