Task 1b: How to Estimate a Ratio of Means using SAS

This section describes how to use SAS to estimate a ratio of means for all adults and for males and females separately.  To illustrate this, the sum of calcium from milk is divided by the sum of total calcium for each population group as an example.

Sorting is not a necessary first step in SAS as it is in SUDAAN.  Therefore, properly weighted estimated means and standard errors, using complex survey design factors (e.g., strata and PSU), can be obtained with the single SAS procedure PROC SURVEYMEANS.

 

Use SAS to Estimate How Much Dietary Calcium Consumed by Adults, Ages 20 Years and Older, Comes from Milk

Sample Code

*-------------------------------------------------------------------------;
* Use the PROC SURVEYMEANS procedure in SAS to compute a properly weighted;
* estimated ratio of means for all persons ages 20+ and by gender.        ;

*-------------------------------------------------------------------------;
* Run analysis for overall subpopulation of interest;

proc surveymeans data=DTTOT;
      where usedat=1 ;
      strata SDMVSTRA;
      cluster SDMVPSU;
      weight WTDRD1;
      var D1MCALC DR1TCALC;
      ratio D1MCALC / DR1TCALC;
      title " Ratio of Means -- All Persons ages 20+" ;
run ;

*-------------------------------------------------------------------------;
* Use the PROC SORT procedure to sort the data by gender.                 ;
*-------------------------------------------------------------------------;

proc sort data =DTTOT;
      by RIAGENDR;
run ;

* Run analysis by gender within subpopulation of interest;

proc surveymeans data=DTTOT;
      where usedat= 1 ;
      strata SDMVSTRA;
      cluster SDMVPSU;
      weight WTDRD1;
      var D1MCALC DR1TCALC;
      ratio D1MCALC / DR1TCALC;
      by RIAGENDR;
      title " Ratios of Means -- by Gender" ;
run ;

 

Output of Program


Ratio of Means -- All Persons ages 20+         

            Data Summary                    
         
Number of Strata                  15        
Number of Clusters                30        
Number of Observations          4448        
Sum of Weights             205284669        
                        
            Statistics                      
         
                                                          Std Error       Lower 95%       Upper 95%  
Variable    Label                 N            Mean         of Mean     CL for Mean     CL for Mean 
--------------------------------------------------------------------------------------------------- 
d1mcalc     Calcium (mg)       4448      101.162167        7.647887       84.861081      117.463253 
DR1TCALC    Calcium (mg)       4448      880.130855       16.722099      844.488545      915.773166 
---------------------------------------------------------------------------------------------------  
                       
     Ratio Analysis                         
         
Numerator Denominator            N           Ratio         Std Err     95% Confidence Interval 
-----------------------------------------------------------------------------------------------   
d1mcalc   DR1TCALC            4448        0.114940        0.006826        0.100390     0.129490 
----------------------------------------------------------------------------------------------- 

Ratios of Means -- by Gender                   

Gender - Adjudicated=male                   

            Data Summary                    
         
Number of Strata                  15        
Number of Clusters                30        
Number of Observations          2135        
Sum of Weights            98664010.2        
          
            Statistics                      
         
                                                        Std Error       Lower 95%      Upper 95% 
Variable    Label               N            Mean         of Mean     CL for Mean    CL for Mean  
------------------------------------------------------------------------------------------------- 
d1mcalc     Calcium (mg)       2135      122.142347     8.719800      103.556533      140.728162 
DR1TCALC    Calcium (mg)       2135      998.359501    21.809584      951.873474     1044.845528  
------------------------------------------------------------------------------------------------  
         
     Ratio Analysis                         
         
Numerator Denominator            N           Ratio         Std Err     95% Confidence Interval  
----------------------------------------------------------------------------------------------- 
d1mcalc   DR1TCALC            2135        0.122343        0.007148        0.107107     0.137579 
-----------------------------------------------------------------------------------------------  

Gender - Adjudicated=female                 
         
            Data Summary                    
         
Number of Strata                  15        
Number of Clusters                30        
Number of Observations          2313        
Sum of Weights             106620659        
         
            Statistics                      
         
                                                        Std Error      Lower 95%       Upper 95% 
Variable    Label               N           Mean         of Mean     CL for Mean     CL for Mean 
------------------------------------------------------------------------------------------------ 
d1mcalc     Calcium (mg)     2313      81.747649        9.880726       60.687380      102.807918 
DR1TCALC    Calcium (mg)     2313     770.725113       15.292108      738.130756      803.319469 
------------------------------------------------------------------------------------------------  
         
     Ratio Analysis                         
         
Numerator Denominator            N           Ratio         Std Err     95% Confidence Interval  
-----------------------------------------------------------------------------------------------
d1mcalc   DR1TCALC            2313        0.106066        0.011329        0.081919     0.130213 
-----------------------------------------------------------------------------------------------   

Highlights from the output include:

 

close window icon Close Window to return to module page.