- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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,, ,
;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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) ??
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is it a way to format the number to one digit after the decimal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, assign the proper format to the variable.
Paige Miller