Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mounikag
Obsidian | Level 7

Hi ,

 

I have a parameter with lab test values(aval) at two different visits(day1, week4). So i need calculate a Geometric Mean Ratio for  (Week 4 Antibody Level / Day 1 Antibody Level). for a parameter by vaccine group at week 4

 

Below is the example:

 

subject      paramcd      avisit             aval       GMR

101            aaa             day1             1.3          ?

101            aaa             week4          2.2

102            aaa             day1             1.1

102            aaa             week4           3.3

103            aaa             day1             2.8

103            aaa             week4           4.7

 

How to calculate GMR varaible and also  a 95%cI

Please provide your insights with an example . so it would be helpful to me .. Thanks in Advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Thanks for the improved code and the explanations.


@mounikag wrote:
5. We need to calculate 95% CI using clopper pearson method for particular geometric ratio

The geometric means are calculated from antibody levels (measured on a continuous scale). As I said, the "Clopper-Pearson method" I know is applicable to binomial proportions (see PROC FREQ documentation), which I don't see in your data or code.

 

6. what i meant is i need to keep the value of geometric mean ratio between day1 / week 4. so i need to calculate GMR across two visists for each parameter. so how i have to calculate to get the value of GMR? Please take the example of 101 subject at day1 the avla value is 1.3 and week 4 value is 2.2 so what will be the GMR value between these two aval values? could you please let me know your inputs with a code

Geometric means (and means in general) are calculated as a summary of two or more values, not for a single value of one subject. So I would expect these to be calculated from the AVAL values of several subjects (as shown in my first reply). The GMR would serve as a summary measure of all the individual ratios (like 2.2/1.3 for subject 101), e.g., within a treatment group.


View solution in original post

6 REPLIES 6
FreelanceReinh
Jade | Level 19

Hi @mounikag,

 

Following Example 127.5 Equivalence Testing with Lognormal Data from the PROC TTEST documentation I suggest this -- assuming that your dataset is already sorted by PARAMCD SUBJECT:

/* Create sample data */

data have;
input subject $ paramcd $ avisit $ aval;
cards;
101 aaa day1 1.3
101 aaa week4 2.2
102 aaa day1 1.1
102 aaa week4 3.3
103 aaa day1 2.8
103 aaa week4 4.7
;

/* Get Day 1 and Week 4 values into separate variables */

proc transpose data=have out=trans(drop=_name_);
by paramcd subject;
var aval;
id avisit;
run;

/* Compute the GMR Week 4 / Day 1 for AVAL (for each PARAMCD) */

ods select none;
ods output conflimits=want(keep=paramcd ratio--UpperCLGeomMean
                           rename=(GeomMean=GMR LowerCLGeomMean=LowerCL_GMR UpperCLGeomMean=UpperCL_GMR));
proc ttest data=trans dist=lognormal;
by paramcd;
paired week4*day1;
run;
ods select all;

proc print data=want;
run;

Result:

                                              LowerCL_    UpperCL_
Obs    paramcd       Ratio             GMR      GMR         GMR

 1       aaa      week4 / day1      2.0426      0.8933      4.6704
mounikag
Obsidian | Level 7

Hi reinhard,

Thanks for quick reply.. *Below is the sample code i am using to generate the output to pass the GMR variable value into the below aval value.
I am using proc means procedure dataset to generate 95%CI. Could you please use below code and i need to pass the GMR value of week4/day1
instead of aval value. I will provide the sample output how i need. As you suggested, I am using the proc ttest but i am not getting the answer.
Basically i need to pass GMR value between the visits instead of aval value

* Create sample data */;

data have;
input subject $ paramcd $ avisit $ aval;
cards;
101 aaa day1 1.3
101 aaa week4 2.2
102 aaa day1 1.1
102 aaa week4 3.3
103 aaa day1 2.8
103 aaa week4 4.7
104 aaa day1 3.8 2
104 aaa week4 4.8 2
105 aaa day1 2.8 3
105 aaa week4 5.7 3
106 aaa day1 3.7 3
106 aaa week4 4.8 3
;
run;


proc sort data=have ;
by avisit trt01pn ;
run ;
proc means data=have;
class avisit trt01pn;
var aval;
output out=mean n=n nmiss=nmiss mean=mean lclm=lclm uclm=uclm;
run;

data gma;
set mean;
keep avisit n1 gmc1 lcl1 ucl1;
where _type_=7 and &tgroup.=1.;
n1=n;
gmc1=10**mean;
lcl1=10**lclm;
ucl1=10**uclm;
run;

data gmb;
set mean;
keep avisit n2 gmc2 lcl2 ucl2;
where _type_=7 and &tgroup.=2.;
n2=n;
gmc2 =10**mean;
lcl2=10**lclm;
ucl2=10**uclm;
run;

proc glm data=have PLOTS(MAXPOINTS= 10000);
by avisit ;
class trt01pn;
model aval = trt01pn ;
means trt01pn / t cldiff clm;
ods output cldiffs=dmean ModelAnova=anova;
run;

data rgm ;
set dmean;
where comparison="1 - 2";
keep avisit rgmc rlcl rucl;
rgmc=10**difference;
rlcl=10**lowercl;
rucl=10**uppercl;
run;

proc sort data=gma;
by avisit ;
proc sort data=gmb;
by avisit ;
proc sort data=rgm;
by avisit ;
run;

data final;
merge gma gmb rgm ;
by avisit ;
run;


 

Capture.PNG

 

 

 

FreelanceReinh
Jade | Level 19

Thanks for providing code and a sample output. I'm not sure I understand what you're trying to do, partly because of inconsistencies in your code:

  • Dataset HAVE does not contain a variable TRT01PN (but a variable PARAMCD), so neither the first PROC SORT step nor the PROC MEANS step will work.
  • The WHERE conditions in the DATA steps following the PROC MEANS step seem to use a treatment group variable, but the definition of macro variable TGROUP is not shown.
  • The WHERE condition _type_=7 will never be met as long as the PROC MEANS step uses only two CLASS variables. Three (or more) CLASS variables would be needed.
  • You write "I am using the proc ttest," but it looks rather like you are using PROC GLM.
  • The footnote of your sample output states that the confidence intervals are calculated using the Clopper-Pearson method. I'm only familiar with the Clopper-Pearson confidence interval for a binomial proportion, but I don't see where a binomial proportion is involved in your data.
  • What do you mean by "pass the GMR variable value into the below aval value"?
mounikag
Obsidian | Level 7
HI ,

1. Sorry i forgot to add treatment variable in the dataset. I added now its in the below dataset and i updated my code as per your comments .
2. I forgot to update tgroup macro to required variable now its updated in the below code.
3. Yes you are right i should use _type_=3 in proc means updated in the below code.
4. what i meant is previously i used proc ttest in separate code but it didnt worked so i changed the code to apply PROC GLM
5. We need to calculate 95% CI using clopper pearson method for particular geometric ratio
6. what i meant is i need to keep the value of geometric mean ratio between day1 / week 4. so i need to calculate GMR across two visists for each parameter. so how i have to calculate to get the value of GMR? Please take the example of 101 subject at day1 the avla value is 1.3 and week 4 value is 2.2 so what will be the GMR value between these two aval values? could you please let me know your inputs with a code

data have;
input subject $ paramcd $ avisit $ aval; trt01pn
cards;
101 aaa day1 1.3 1
101 aaa week4 2.2 1
102 aaa day1 1.1 2
102 aaa week4 3.3 2
103 aaa day1 2.8 1
103 aaa week4 4.7 1
104 aaa day1 3.8 2
104 aaa week4 4.8 2
105 aaa day1 2.8 3
105 aaa week4 5.7 3
106 aaa day1 3.7 3
106 aaa week4 4.8 3
;
run;


proc sort data=have ;
by avisit trt01pn ;
run ;
proc means data=have;
class avisit trt01pn;
var aval; (GMR value ?)
output out=mean n=n nmiss=nmiss mean=mean lclm=lclm uclm=uclm;
run;

data gma;
set mean;
keep avisit n1 gmc1 lcl1 ucl1;
where _type_=3 and trt01pn =1;
n1=n;
gmc1=10**mean;
lcl1=10**lclm;
ucl1=10**uclm;
run;

data gmb;
set mean;
keep avisit n2 gmc2 lcl2 ucl2;
where _type_=3 and trt01pn=2;
n2=n;
gmc2 =10**mean;
lcl2=10**lclm;
ucl2=10**uclm;
run;

proc glm data=have PLOTS(MAXPOINTS= 10000);
by avisit ;
class trt01pn;
model aval = trt01pn ;
means trt01pn / t cldiff clm;
ods output cldiffs=dmean ModelAnova=anova;
run;

data rgm ;
set dmean;
where comparison="1 - 2";
keep avisit rgmc rlcl rucl;
rgmc=10**difference;
rlcl=10**lowercl;
rucl=10**uppercl;
run;

proc sort data=gma;
by avisit ;
proc sort data=gmb;
by avisit ;
proc sort data=rgm;
by avisit ;
run;

data final;
merge gma gmb rgm ;
by avisit ;
run;
FreelanceReinh
Jade | Level 19

Thanks for the improved code and the explanations.


@mounikag wrote:
5. We need to calculate 95% CI using clopper pearson method for particular geometric ratio

The geometric means are calculated from antibody levels (measured on a continuous scale). As I said, the "Clopper-Pearson method" I know is applicable to binomial proportions (see PROC FREQ documentation), which I don't see in your data or code.

 

6. what i meant is i need to keep the value of geometric mean ratio between day1 / week 4. so i need to calculate GMR across two visists for each parameter. so how i have to calculate to get the value of GMR? Please take the example of 101 subject at day1 the avla value is 1.3 and week 4 value is 2.2 so what will be the GMR value between these two aval values? could you please let me know your inputs with a code

Geometric means (and means in general) are calculated as a summary of two or more values, not for a single value of one subject. So I would expect these to be calculated from the AVAL values of several subjects (as shown in my first reply). The GMR would serve as a summary measure of all the individual ratios (like 2.2/1.3 for subject 101), e.g., within a treatment group.


mounikag
Obsidian | Level 7
Thanks .. for clarification. I got your point .. thanks for taking time to answer my questions. It was so helpful

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 6 replies
  • 7345 views
  • 5 likes
  • 2 in conversation