BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
AllEpi
Fluorite | Level 6

Hello

 

I am looking to distribution of biomakers. I am interested to estimate age and sex adjusted medians for these variables. Is there a way to do it? This paper has decscribed it but unfortunately the SAS code is not provided (https://pubmed.ncbi.nlm.nih.gov/19028825/). 

 

Any support will be appreciated. 

Best wishes
AllEpi

1 ACCEPTED SOLUTION

Accepted Solutions
AllEpi
Fluorite | Level 6

Thank you for the suggestion. To clarify my question, this is about how to get the adjusted medians

in SAS. Now I am interested in getting Medians of the diastolic blood pressure across the quantiles of 

of the systolic blood pressure but adjusted for ageatstart and sex in the sashelp.heart dataset. 

When I run your code I get "Non-est". I get the same message, if I change the variable. Any further toughts on this?Example.PNG

View solution in original post

9 REPLIES 9
StatDave
SAS Super FREQ

Look into using PROC QUANTREG.

AllEpi
Fluorite | Level 6

Thank you for the helpful posts. My question was related to getting adjusted medians. I am aware of how to get quartile with confidence intervals from a post by @Rick_SAS  (https://blogs.sas.com/content/iml/2017/02/22/difference-of-medians-sas.html). However, that gives me unadjusted medians as there is nothing on the right side of the model!. 

There is also option to predict the quantiles. Using this approach, I proceed to calculate the adjusted (predicted medians, using q=0.5). For example in the sashelp.heart study if I am interested to know the median of the diastolic blood pressure across the quartiles of the systolic pressure, this is how I got the medians adjusted for age at start and sex. 

*First I make quartiles of the systolic blood pressure;

proc rank data=sashelp.heart groups=4 out=heart;
var Systolic;
ranks sys;
run;

 

*Then I get age and sex adjusted predicted diastolic blood pressure; 
proc quantreg data=heart ci=sparsity/iid algorithm=interior(tolerance=1.e-4);
class sex;
model diastolic =ageatstart sex / quantile=0.5;
output out=predictquant p=predquant;
run;

 

"Then I get adjusted medians (from predicted systolic blood pressure called predquant) across the quartiles of systolic blood pressure (sys), I keep original variable to get the difference in medians;

proc means data=predictquant median;

class sys;
var diastolic predquant ;
run;

 

I can see that the difference between median of the original variable and predicted (which is adjusted for age and sex).  On a side note, to cross check my result when I added used height only for adjustment (assuming it will be less related to diastolic blood pressure), I get median of the original as well as predicted diastolic blood pressure as same. 

Now the question is: Is this a correct approach to get adjusted medians (The question is not about whether this is a correct data anlaysis approach!)

 

Thanks in advance

Ksharp
Super User

"adjusted medians "  for what ? or how to get it ?

If you means it like Linear Regression Model , you can use LSMEANS or ESTIMATE to get it ,as you showed Rick blog:

https://blogs.sas.com/content/iml/2017/02/22/difference-of-medians-sas.html

 

proc quantreg data=heart ci=sparsity algorithm=interior(tolerance=1.e-4);
class sex;
model diastolic =ageatstart sex / quantile=0.5;
estimate 'Adjusted Medians of Female' sex 1 0 / CL;
estimate 'Adjusted Medians of Male' sex 0 1 / CL;
run;

 

 

AllEpi
Fluorite | Level 6

Thank you for the suggestion. To clarify my question, this is about how to get the adjusted medians

in SAS. Now I am interested in getting Medians of the diastolic blood pressure across the quantiles of 

of the systolic blood pressure but adjusted for ageatstart and sex in the sashelp.heart dataset. 

When I run your code I get "Non-est". I get the same message, if I change the variable. Any further toughts on this?Example.PNG

Ksharp
Super User

Opps. I missed a INTERCEPT term to score a set of X variables when using ESTIMATE.

 

proc quantreg data=sashelp.heart ci=sparsity algorithm=interior(tolerance=1.e-4);
class sex;
model diastolic =systolic ageatstart sex / quantile=0.5;
estimate 'Adjusted Medians of diastolic when systolic=148,ageatstart=33,sex=Female' 
         intercept 1 systolic 148  ageatstart 33 sex 1 0 / CL;
run;

Here 148 is 75 percentile of systolic ,33 is 50 percentile of ageatstart.

Ksharp_0-1738718582106.png

 

 

AllEpi
Fluorite | Level 6
Thank you so much. It was really very helpful. I have two short questions i) if systolic is a categorized in 4 levels (quartile). How can I specify each level? ii) How is this approach different from the predicted approach (the one that I showed in the original post?). Kind regards
Ksharp
Super User
"if systolic is a categorized in 4 levels (quartile). "
No. Here I take systolic as a continuous variable not category variable, if you want bin it as a category varible with four levels. you need put it in CLASS statment.
proc quantreg data=sashelp.heart ci=sparsity algorithm=interior(tolerance=1.e-4);
class sex systolic ;
model diastolic =systolic ageatstart sex / quantile=0.5;
estimate 'Adjusted Medians of diastolic when systolic=1,ageatstart=33,sex=Female'
intercept 1 systolic 1 0 0 0 ageatstart 33 sex 1 0 / CL;
run;


" How is this approach different from the predicted approach"
Honestly, I don't understand your code . It looks like you take systolic as a category variable , but I take it as a continuous variable.
Also I have no time to go through the paper you posted .
StatDave
SAS Super FREQ

The analysis you showed with PROC RANK and PROC QUANTREG looks reasonable to me.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is ANOVA?

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.

Discussion stats
  • 9 replies
  • 730 views
  • 11 likes
  • 3 in conversation