Nutrient Variables
These are macro variable statements that can be copied and pasted into a SAS program. These are the 30 nutrient variables used in USDA data sets at CPC.
** All 30 nutrients **; ** 1 2 3 4 5 6 7 8 9 10 11 **; %let name1=energy protein carbo tfat sfat choles calcium folate iron zinc fiber ; %let nut1=kcal94 protn94 carb94 fat94 satf94 chol94 calc94 fola94 iron94 zinc94 fiber94 ; %let nut1_1=kcal1 protn1 carb1 fat1 satf1 chol1 calc1 fola1 iron1 zinc1 fiber1 ; %let nut2_1=kcal2 protn2 carb2 fat2 satf2 chol2 calc2 fola2 iron2 zinc2 fiber2 ; %let nut3_1=kcal3 protn3 carb3 fat3 satf3 chol3 calc3 fola3 iron3 zinc3 fiber3 ; %let d2nut1=d2kcal d2protn d2carb d2fat d2satf d2chol d2calc d2fola d2iron d2zinc d2fiber ; %let d3nut1=d3kcal d3protn d3carb d3fat d3satf d3chol d3calc d3fola d3iron d3zinc d3fiber ; ** 12 13 14 15 16 17 18 19 20 21 22 **; %let name2=sodium vita_re vite vitc thiamin ribo niacin vitb6 vitb12 phos magnes ; %let nut2=sodium94 are94 e94 c94 thia94 ribo94 niacin94 b694 b1294 phos94 mag94 ; %let nut1_2=sodium1 vare1 ve1 vc1 thia1 ribo1 niacin1 vb6_1 vb12_1 phos1 mag1 ; %let nut2_2=sodium2 vare2 ve2 vc2 thia2 ribo2 niacin2 vb6_2 vb12_2 phos2 mag2 ; %let nut3_2=sodium3 vare3 ve3 vc3 thia3 ribo3 niacin3 vb6_3 vb12_3 phos3 mag3 ; %let d2nut2=d2sodium d2vare d2ve d2vc d2thia d2ribo d2niac d2vb6 d2vb12 d2phos d2mag ; %let d3nut2=d3sodium d3vare d3ve d3vc d3thia d3ribo d3niac d3vb6 d3vb12 d3phos d3mag ; ** 23 24 25 26 27 28 29 30 **; %let name3=vita_iu mfat pfat caro alcohol copper potass water ; %let nut3=aiu94 monof94 polyf94 carot94 alc94 copper94 potass94 water94 ; %let nut1_3=aiu1 monof1 polyf1 carot1 alc1 copper1 potass1 water1 ; %let nut2_3=aiu2 monof2 polyf2 carot2 alc2 copper2 potass2 water2 ; %let nut3_3=aiu3 monof3 polyf3 carot3 alc3 copper3 potass3 water3 ; %let d2nut3=d2aiu d2monof d2polyf d2carot d2alc d2copper d2potass d2water ; %let d3nut3=d3aiu d3monof d3polyf d3carot d3alc d3copper d3potass d3water ;
The following is some code that can be added to a program that will read the macro variables above and assign them to a text string variable. Since SUDAAN's output data sets contains only the numeric order of the variables in the results, this code can add the variable name to your results. The first time you use this code you should ask Phil Bardsley for assistance.
** create text string for variable names **;
data new;
set sudaan_output; *** "variable" is a var created by SUDAAN. It is the
number that represents the order the variable occurs
in the var statement in the SUDAAN procedure...
Make sure that the variables above are in the same order
as the vars in the var statement! ***;
** read in macro variables as text strings for variable identification **;
if 1<=variable<=11 then var=left(substr("&nut1.",(variable*9)-8,8));
else
if 12<=variable<=22 then var=left(substr("&nut2.",((variable-11)*9)-8,8));
else
if 23<=variable<=30 then var=left(substr("&nut3.",((variable-22)*9)-8,8));
run;
proc print data=out.cr99961r(obs=20);
var variable var;


