Page 1 of 1
Loop
Posted: April 11th, 2023, 11:35 am
by BK Singh
Dear sir/mam,
I have a HouseHold roster with question Q1-name, Q2-sex, Q3-age and out of roaster I have Q5- Respondent age is to be entered. I need a logic which will check the age entered in Q5 is matching with any age entered in Q3 if not then errmsg should appear.
I am trying creating loop but the errmsg appears for every occurrence of Q3 which is not equal to the number entered.
Logic:-
do i = 1 while i <= Q3(i)
if Q5<>Q3(i) then
errmg(",,,,,,,");
endif;
endo;
Re: Loop
Posted: April 11th, 2023, 12:28 pm
by etuser
may be
if not Q3 has Q5 then
errmsg (".....");
endif;
Re: Loop
Posted: April 11th, 2023, 1:02 pm
by BK Singh
thank you sir...
But is there any other way
Re: Loop
Posted: April 12th, 2023, 2:44 am
by khurshid.arshad
Dear;
I've developed an app that works for two different items, Q4 and Q8. Q4 is for entering the age of household members and Q8 is for finishing entering members.
In Q4, when you enter the age, the app compares the name from Q2 and R_Q1. If they match and the age in Q4 and R_Q2 don't match, an error message pops up with two options. You can amend the age either in Q4 or R_Q2, based on your selection.
The second block of code is for Q8. When you finish entering members, the seek function searches for the respondent's name in the roster. If it's found, nothing happens. If it's not found, the do-while loop shows a list of members with two options: 1) Edit respondent name; 2) Add another member.
If you select a name from the list, you can edit the name. If you select the second last option, you can edit the respondent name in R_Q1. If you select the last option, you can add another member to the roster for the respondent. I hope this app works well for you!
Best.
a.
Re: Loop
Posted: April 12th, 2023, 6:41 am
by BK Singh
Dear Arshad.Khursheed sir,
I have watched all you youtube videos. Can you please make a detailed video on types of loop.
Thank you
Re: Loop
Posted: April 12th, 2023, 6:41 am
by BK Singh
by the way thank you for the help