Looping within second level

Discussions about CSEntry
Post Reply
Guest

Looping within second level

Post by Guest »

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!
Guest

Re: Looping within second level

Post by Guest »

This works when I put HH & WM in one application and Birth Registration in another.
Gregory Martin
Posts: 1792
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Looping within second level

Post by Gregory Martin »

Do you still have your original question, or are you satisfied with the way you have resolved the problem?

Instead of using levels, I prefer to split my sections across applications and use the loadcase function if I need to lookup data created in a different application. For example, if logic in the birth registration application had to reference data entered in the woman's questionnaire, you could access the woman's data from to retrieve the relevant information.
Guest

Re: Looping within second level

Post by Guest »

Hi Greg,
I’m trying to learn both methods, following along with someone else’s files. I have the HH & WM in one application with a menu after the women have been entered the go to the birth registration application.
I’ve taken the following steps:
1. made an external dictionary, that's attached to both applications, for the shared variables
2. defined alpha variables of the appropriate length for cluster and hh (the ID variables in the ext. dict)
3. defined the parameter using concatenated hh and cluster
4. used loadcase and writecase to get the other variables that I’ll need (U5LINE, U5NAME…)

I am able to get the hh and cluster number to appear in the fields of the birth registration application using:
$ = tonumber(strip(sysparm()[1:3]))
I thought I could call up the other variables with loadcase, but am having trouble doing that.
Emily
Gregory Martin
Posts: 1792
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Looping within second level

Post by Gregory Martin »

Loadcase requires that the parameter that you search for must exactly match the ID in the data file.

Is there a reason you are making the cluster and HH IDs alpha in your dictionary? Those IDs should be identical to the IDs in the dictionary used to create the data file from which you will load data. Make sure that, if they are numeric, that the Zero Fill attribute is also identical.

If that still does not work, perhaps you can share you loadcase function call and we can check if there is an error.
emilywilson
Posts: 3
Joined: June 14th, 2012, 3:03 pm

Re: Looping within second level

Post by emilywilson »

I'm not sure why the conversion to string and then back to number. Everything is loading correctly though. Thanks very much!
Post Reply