Hello,
I have a dataset shown below. I would like to get mean/median/IQR/sum/sum_percent in each "Lab/Pham/Diag" group, excluding the missing values. Please let me know how to approach, thanks.
data Bill;
length caseid $10 Lab 3 Pham 4 Diag 4;
infile datalines delimiter=',';
input Caseid Lab Pham Diag;
datalines;
EC1R00002,200,6000,5500,
AC1R00012,100, , 7000,
EC1R00013,50,3800, ,
BH1U00185, ,4600,1500,
EN1R01252,700,9000,2900,
CY1K01251, ,500, ,
BH1U99185,900,5600,8500,
OP1R00252,360,9900,8900,
PCHK01401,770,, ,
;
I don't know what you mean by "sum_percent"
Otherwise, this gets the job done:
proc means data=bill stackodsoutput mean median p25 p75 sum;
ods output summary=summary;
var lab pham diag;
run;
You will have to compute the IQR from the p75 and p25 values.
I don't know what you mean by "sum_percent"
Otherwise, this gets the job done:
proc means data=bill stackodsoutput mean median p25 p75 sum;
ods output summary=summary;
var lab pham diag;
run;
You will have to compute the IQR from the p75 and p25 values.
@ybz12003 wrote:
Lab (Sum_%)= Lab_sum / [Sum(Lab+Pha+Dia)]
I'm not sure what this means. From the data you posted, the sums are
LAB 3080
PHAM 39400
Diag 34300
So are you asking for code to compute 3080/(3080+39400+34300) ??
proc means data=bill stackodsoutput mean median p25 p75 sum;
ods output summary=summary;
var lab pham diag;
run;
proc sql;
create table want as select
*,
sum / sum(sum) as sum_pct
from summary;
quit;
Is it a way to format the number to one digit after the decimal?
Yes, assign the proper format to the variable.
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!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.