SAS Code to Create Food Security Composite Variables Directly from the ECLS-K 1998-99 Child Data File Note: The following SAS code can be found in Appendix D of the ECLS-K 1998-99 Food Security Status File Technical Documentation and User Notes. *read 18 scale variables and create food security composite variables; data temp.eclsfood (keep=childid p2fsraw p2fsscal p2fsstat); infile 'f:\child.dat' lrecl=5305; input #1 childid $ 1-8 p2worrfd 4058-4059 p2fdlast 4060-4061 p2blmeal 4062-4063 p2lowcst 4064-4065 p2nobal 4066-4067 p2cantaf 4068-4069 p2evcut2 4070-4071 p2evcut 4072-4073 p2eatles 4074-4075 p2hungry 4076-4077 p2losewt 4078-4079 p2noteat 4080-4081 p2notea2 4082-4083 p2cutml 4084-4085 p2chskip 4086-4087 p2oftcut 4088-4089 p2chievr 4090-4091 p2nomony 4092-4093 #2 #3; array qfood{18} p2worrfd p2fdlast p2blmeal p2lowcst p2nobal p2cantaf p2evcut2 p2evcut p2eatles p2hungry p2losewt p2noteat p2notea2 p2cutml p2chskip p2oftcut p2chievr p2nomony; array hhsc{18} hhsc1-hhsc18; *household scores corresponding to raw scores; *set household scores for each raw score; *based on Guide to Measuring Household Food Security, 2000; *standard (logit-unit) computational metric, appendix C-2, page 71; hhsc1=1.4; hhsc2=2.6; hhsc3=3.4; hhsc4=4.1; hhsc5=4.8; hhsc6=5.4; hhsc7=6.0; hhsc8=6.6; hhsc9=7.2; hhsc10=7.7; hhsc11=8.3; hhsc12=8.8; hhsc13=9.3; hhsc14=9.8; hhsc15=10.4; hhsc16=11.1; hhsc17=12.2; hhsc18=13.0; *identify valid cases and accumulate affirmative responses; cvalid='no'; p2fsraw=0; do i=1 to 18; *each item; if qfood{i} gt 0 then do; *valid response; cvalid='ok'; if qfood{i} eq 1 then p2fsraw=p2fsraw+1; else if i in (1,2,3,4,5,6,8,13,16) and qfood{i} eq 2 then p2fsraw=p2fsraw+1; end; *of valid response; end; *of each item; *assign scale scores and categorical variable; if cvalid eq 'no' then do; *no valid response; p2fsraw=-9; p2fsscal=-9; p2fsstat=-9; end; *of no valid response; else do; *1 or more valid response; if p2fsraw eq 0 then p2fsscal=-6; else p2fsscal=hhsc{p2fsraw}; if p2fsraw ge 13 then p2fsstat=4; else if p2fsraw ge 8 then p2fsstat=3; else if p2fsraw ge 3 then p2fsstat=2; else p2fsstat=1; end; *of one or more valid response; run;