Dear users,
I use Stata 8.0. I haven't seen an example of doing loop by stata, and
not sure of the right command to use. Now I have a set of SAS codes, and
need to translate it into Stata. Can anybody give me a hint how to do
this? The SAS codes are:
---------------------------------
array qflag{5} aaflast aafbaln aafskip aafless aafday; *allocation flags;
array qraw{5} eaflast eafbaln eafskip eafless eafday; *food security scale
variables;
aafdsec=0; *flag for no imputation;
rafsraw=0; *raw score counter;
do q=1 to 5; *each item;
if qflag{q} eq 1 then aafdsec=1;
if q in (1,2) and qraw{q} in (1,2) then rafsraw=rafsraw+1;
*often/sometimes/never item;
else if q in (3,4,5) and qraw{q} eq 1 then rafsraw=rafsraw+1; *yes/no item;
end; *of each item;
if rafsraw eq 0 then do; rafsscal=-6; rafsstat=1; end;
else if rafsraw eq 1 then do; rafsscal=3.16; rafsstat=1; end;
else if rafsraw eq 2 then do; rafsscal=4.39; rafsstat=2; end;
else if rafsraw eq 3 then do; rafsscal=5.53; rafsstat=2; end;
else if rafsraw eq 4 then do; rafsscal=7.54; rafsstat=3; end;
else if rafsraw eq 5 then do; rafsscal=9.14; rafsstat=3; end;
*scale scores are based on standard CPS 1998 item scores for the items in
the sipp scale;
*with discrimination set to 1.58 to reflect the actual discrimination of
sipp items;
run;
---------------
Thanks in advance.
Ying
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/