Hello,
I have a sample code below; I would like to calculate the age and ICU column percent of Sum_cost. Is there a way to approach it? Thanks.
proc tabulate data=DataIn;
var Cost_Sum;
class age ICU;
table (age ICU),(Cost_Sum) *(N mean std median p25 p75 sum);
run;
Hi;
While this might be a bit over-simplified, perhaps it'll get you on your way:
data datain;
infile datalines;
input age icu cost_sum;
datalines;
17 1 10000
65 1 13250
44 2 6200
89 2 23000
;
proc format;
picture perc (round) low-high='09.99%' (multiplier=100);
run;
proc tabulate data=datain;
var cost_sum;
class age icu;
table(age icu),(cost_sum) * (n mean std median p25 p75 sum pctsum *f=perc.);
run;
I've used the pctsum keyword, one of Cynthia's suggestions, but often programmers have difficulty getting the needed '%' sign to appear. To do this, you'll need to create your own format as I've done above, using a 'picture' statement instead of the usual value statement. Here are some results using the make-believe dataset above:
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.