*-------------------------------------------------------------------------; * This program is used to estimate the mean intake, in grams, of ; * fluid milk drunk by itself (not in combination with any ; * other item) by all children 6-11 in the United States. Estimates of ; * calcium intake from all foods and beverages. ; * These estimates are based on day 1 dietary recall intakes ; *-------------------------------------------------------------------------; *-------------------------------------------------------------------------; * The LIBNAME statement is used to denote the location where the data will; * be stored. ; * ; * Use SAS options to format the output ; *-------------------------------------------------------------------------; options linesize=78; options nofmterr; libname NH "C:\NHANES\DATA"; *-------------------------------------------------------------------------; * Use the PROC SORT procedure to sort the data files, by sequence number ; * (SEQN) that will be merged. Note that the files come from the NH ; * library assigned in the previous step ; * ; * Merge the 2003-2004 Day 1 Individual Foods File (IFF) with the ; * demographics file. Use the KEEP statement to retain food-level records ; * of interest (fluid milk consumed not in combination with another food ) ; * from the IFF file by selecting on food code and combination number. ; *-------------------------------------------------------------------------; proc sort data=NH.DR1IFF_C out=DR1IFF_C; by SEQN; run; proc sort data=NH.DEMO_C out=DEMO_C; by SEQN; run; data DEMO1IFF; merge DR1IFF_C (in=i keep = SEQN DR1CCMNM DR1IFDCD DR1IGRMS where = ((11100000 <= DR1IFDCD <= 11299999) and (DR1CCMNM eq 0))) DEMO_C (keep=SEQN RIDAGEYR); by SEQN; if i; run; *-------------------------------------------------------------------------; * Use the PROC CONTENTS procedure to list the contents of the DEMO1IFF ; * dataset - the new merged dataset. Use the VARNUM option to list the ; * variables according to their position in the dataset. ; * ; * Use the PROC MEANS procedure to determine the number of non-missing ; * values (N), number of missing values (Nmiss), minimum (min) and maximum ; *(max) values, to two decimal places (maxdec=2), for the variables in the ; * merged dataset. ; *-------------------------------------------------------------------------; proc contents data=DEMO1IFF varnum; proc means data= DEMO1IFF N Nmiss min max maxdec=2; run; *-------------------------------------------------------------------------; * Use the PROC MEANS procedure to accumulate the daily totals of milk ; * amounts for each child consuming milk not in combination that ; * day. ; * ; * The variable containing the daily totals is named MILK0 ; * ; * The results will be output in a new file called DATA2. Only individuals ; * with non-zero values of MILK0 are represented in DATA2. ; *-------------------------------------------------------------------------; proc means noprint data = DEMO1IFF; by SEQN; var DR1IGRMS; output out = DATA2 sum = MILK0; run; *-------------------------------------------------------------------------; * Sort the 2003-2004 Day 1 Total Nutrient master file (DR1TOT_C) and the ; * pyramid equivalents file (PYR_TOT_D1). The PYR_TOT_D1 file will be used to ; * get total milk equivalents using the MyPyramid Equivalents database ; *-------------------------------------------------------------------------; proc sort data=NH.DR1TOT_C out=DR1TOT_C; by SEQN; run; proc sort data=NH.PYR_TOT_D1 out=PYR_TOT_D1; by SEQN; run; *-------------------------------------------------------------------------; * Merge the DR1TOT_C, DEMO_C, DATA 2 and PYR_TOT_D1 files. ; * ; * This merge creates a new variable MILK0W0 which also includes ; * individuals NOT in DATA2 with a value of 0 meaning no milk was consumed.; * ; * Use the KEEP statement to retain selected variables in the dataset ; *-------------------------------------------------------------------------; data CALCMILK (keep = SEQN RIDAGEYR RIAGENDR WTDRD1 SDMVSTRA SDMVPSU MILK0 MILK0W0 DR1TCALC D_TOTAL INCOH); merge DR1TOT_C (keep = SEQN DR1TCALC WTDRD1) DEMO_C (keep = SEQN RIDAGEYR RIAGENDR SDMVSTRA SDMVPSU) DATA2 (in = in2) PYR_TOT_D1 (keep= SEQN D_TOTAL); by SEQN; *-------------------------------------------------------------------------; * Use the IF, THEN, and ELSE statements to create a variable called INCOH; * that defines who is in the cohort of interest - children ages 6-11 ; *-------------------------------------------------------------------------; if (6 <= RIDAGEYR <= 11) then INCOH=1; else INCOH=0; *-------------------------------------------------------------------------; * Set MILK0WO equal to 0 if the respondent reported that no ; * milk was drunk by itself on the recall day ; *-------------------------------------------------------------------------; if not in2 then do; MILK0W0 = 0; end; else MILK0W0=MILK0; *-------------------------------------------------------------------------; * Use the LABEL statement to create labels to apply to selected variables ; *-------------------------------------------------------------------------; label MILK0 = "Fluid milk (g) consumed outside of a combination for consumers" MILK0W0 = "Fluid milk (g) consumed outside of a combination for all"; run; *-------------------------------------------------------------------------; * Create a format for gender, which will appear in the output ; *-------------------------------------------------------------------------; proc format; value GENDER 1 = "Male" 2 = "Female"; run; *-------------------------------------------------------------------------; * Use the PROC SURVEYMEANS procedure to SAS to compute properly weighted ; * estimated means and standard errors. ; * ; * To properly perform a subdomain analysis we form a 2-way table of INCOH ; * by RIAGENDR. In this example, the statistics of interest are those ; * where INCOH=1 in the table. ; *-------------------------------------------------------------------------; proc surveymeans nobs mean stderr data = CALCMILK; strata SDMVSTRA; cluster SDMVPSU; domain INCOH*RIAGENDR; var MILK0 D_TOTAL MILK0W0; weight WTDRD1; format RIAGENDR GENDER.; title1 "Estimated daily intake of fluid milk drunk by itself as a beverage; and of total milk and milk products"; title2 "children age 6-11, WWEIA, NHANES 2003-2004 - using SAS"; run; proc surveymeans nobs mean stderr data = CALCMILK; strata SDMVSTRA; cluster SDMVPSU; domain INCOH*RIAGENDR; var DR1TCALC; weight WTDRD1; format RIAGENDR GENDER.; title1 "Estimated daily intake of total Calcium"; title2 "children age 6-11, WWEIA, NHANES 2003-2004 - using SAS"; run; data NH.CALCMILK; set CALCMILK; run;