Looping within second level
Posted: February 19th, 2013, 5:54 pm
I have a three level Q: HH, WM, birth registration. Is there a simpler way to loop within a secondary questionnaire? I'm having trouble - the program goes straight into the birth registration Q (after just one woman) with the code below.
WLINEX identifies line numbers of eligible women from the HH listing
XENTERED tracks women already entered by changing from 2 to 1 if entered in the WMQ
HH2 is HHmember name
WM4 is line number in WMQ
HH12 is total eligible women
PROC WM
preproc
xline = 0;
//Eligible Women & all people
do varying i=1 until i>totocc(GROUP042.WLINEX000)
if WLINEX(i)>0 then
xline=xline+1;
endif;
enddo;
do varying i=1 until i>hhtotal
allpeople(i) = concat(edit("99",i)," ",HL2(i));
enddo;
//Names of people in HH
name1 = allpeople(1);
name2 = allpeople(2);
name3 = allpeople(3);
name4 = allpeople(4);
name5 = allpeople(5);
// If no elegible women then end women's QRE
if !xline then
endlevel;
endif;
postproc
do varying i=1 until i>totocc(GROUP042.WLINEX000)
if WM4 = WLINEX(i) & XENTERED(i) = 2 then
XENTERED(i) = 1;
//break;
endif;
enddo;
if xline then
wenter(rline)=1;
endif;
xwomen = 0;
do i=1 until i>totocc(GROUP042.WLINEX000)
if XENTERED(i)=1 then
xwomen=xwomen+1;
endif;
enddo;
//errmsg("before comparison with welig %2d",xwomen);
if xwomen = HH12 then
endlevel;
endif;
If not, I'll keep troubleshooting this. Thanks!
WLINEX identifies line numbers of eligible women from the HH listing
XENTERED tracks women already entered by changing from 2 to 1 if entered in the WMQ
HH2 is HHmember name
WM4 is line number in WMQ
HH12 is total eligible women
PROC WM
preproc
xline = 0;
//Eligible Women & all people
do varying i=1 until i>totocc(GROUP042.WLINEX000)
if WLINEX(i)>0 then
xline=xline+1;
endif;
enddo;
do varying i=1 until i>hhtotal
allpeople(i) = concat(edit("99",i)," ",HL2(i));
enddo;
//Names of people in HH
name1 = allpeople(1);
name2 = allpeople(2);
name3 = allpeople(3);
name4 = allpeople(4);
name5 = allpeople(5);
// If no elegible women then end women's QRE
if !xline then
endlevel;
endif;
postproc
do varying i=1 until i>totocc(GROUP042.WLINEX000)
if WM4 = WLINEX(i) & XENTERED(i) = 2 then
XENTERED(i) = 1;
//break;
endif;
enddo;
if xline then
wenter(rline)=1;
endif;
xwomen = 0;
do i=1 until i>totocc(GROUP042.WLINEX000)
if XENTERED(i)=1 then
xwomen=xwomen+1;
endif;
enddo;
//errmsg("before comparison with welig %2d",xwomen);
if xwomen = HH12 then
endlevel;
endif;
If not, I'll keep troubleshooting this. Thanks!