NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by gbos »

Dear CSPRO Community, can anyone help, I have rosters roster1 and Roster2. In Roster1, I have a complete listing of all household members. So, ID numbers are sequentially generated for all household members.

In Roster2, ID should come from Roster1 provided they have a holding. Only those household members who responded Yes to ‘is name a holder’ which variable is holder; should be on Roster2. But these IDs being exported must come as a popup list to choice from whenever Holder ID on Roster2 comes into focus. So that, if for instance, if you have 1, 3, 5, 7 selected from Roster1 and exported to Roster2. If You selected 1 in the holder id of Roster2, the second time Holder ID is in focus, the popup list should show 3,5,7 to choose from. You will progress in such a manner on Roster2 until all ID numbers exported are exhausted.
Attached herewith is my survey for urgent attention and help, as am still very new to CSPRO. I should be grateful for any help, ASAP.
I tried the syntax below but that didn’t yield the desired results.

Proc holder_id
onfocus
numeric hholder= seek(hhid where holder = 1);
holder_id = hholder;

Thanks my Regards
A survey.zip
(2.85 KiB) Downloaded 279 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by josh »

If you want to make a popup of the options you need to use a dynamic value set using the setvalueset function. For an example of how to use this see the section "Dynamic Value Sets from a Roster" in the following document:

http://teleyah.com/cspro/SouthAfricaOct2016/05-CAPI.pdf

That example is very similar to yours. The only difference is that instead of looking at sex and age you will look at HOLDER.

The only tricky part is making sure that you don't select the same person twice. For that you can use seek() to see if the value already exists in the second roster. Something like:

Code: Select all

if HOLDER(iRoster1) = 1 and seek(HOLDER_ID = ID1(iRoster1)) = 0 then
  // add to value set
endif;
where iRoster is a counter variable that loops from 1 to the total number of rows in the first roster, i.e. totocc(ROSTER1000)
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by gbos »

Josh,

Many thanks for the help. I tried the suggested coding for a solution, the program compiles fine but NO IDS POPED UP. I adapted the coding for my survey as follows:

PROC S3Q0

onfocus

// Create the value set for Agricultural Holders from Demographic_Roster
// for Holders IDS in Land_Use_ROSTER

numeric iRoster1;
numeric nextEntryValueSet = 1;
do iRoster1= 1 while iRoster1<= totocc(DEMOGRAPHICS_ROSTER)
if S2Q21(iRoster1) = 1 and seek(S3Q0 = S2Q0(iRoster1)) = 0 then
labels(nextEntryValueSet) = S2Q1(iRoster1);
codes(nextEntryValueSet) = iRoster1;
nextEntryValueSet = nextEntryValueSet + 1;
endif;
enddo;

codes(nextEntryValueSet) = notappl;
setvalueset(S3Q0, codes, labels);


I have decided to upload my full survey for your attention and urgent assistance, still am relatively new to CSPRO.
I should be grateful for your urgent attention and help.

Thanks

Regards,
LB_Agric_Sample _Survey.zip
(37.66 KiB) Downloaded 321 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by josh »

Did you change the capture type of S3Q0 to radio button or dropdown? You can do this from the field properties dialog (right click on the field).
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by gbos »

Josh,

I didn't do it previously but now I did here i and this is what I got

'The selected capture type is not compatible with item's first value set.

see the attached screen captured.
Screen capture.docx
(120.27 KiB) Downloaded 308 times
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by khurshid.arshad »

Dear;

You are using Setvalueset Function instead Createing Valueset. Don't worry about this. Your application will work.
Best.
a.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by josh »

That is a warning. You can ignore it.
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by gbos »

Dear Josh,

Thanks it did work. However, is it possible to modify the program, so that the imported HolderId can be duplicating because in some instance, e.g a farm holding can have more than one crop farm. The duplication will allow the capture of all farms or crops associated with one HolderId before capturing the second Holder Id.

Also, how Can I modify the program such that the same set of IDS imported from S2q0 to imported into every other section of the survey with HolderId. I have more than 4 other sections where the same holderIDs must be imported just like it was implemented for SECTION 03.

Thanks in advance for your support.

Regards,
GBOS
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by josh »

If you remove the part with the seek condition then you will be able to duplicate the holder id in the second roster.

To copy the holder id's into other sections just add in the preproc of the field you are copying them into to assign the value of the corresponding occurrence of the field you are copying from. If you are copying from holderid1 to holderid2 then you would do something like:

Code: Select all

PROC holderid2
preproc
holderid2 = holder1(currocc());
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Re: NEEDED HELP URGENTLY TO DUPLICATE THE SAME IDS FROM ONE ROSTER1 TO ROSTER2

Post by gbos »

Dear Josh,

Many thanks for the support. I remained most grateful. I am glad that getting IDs from Roster1 to all the rosters is now working perfectly in my application. Thanks once more.

However for some of the Rosters, I want the copied ID to be duplicated atleast or spaces to be inserted to allow for some sequential numbering of some second variable before getting to next copied ID. I have attached a spreadsheet to illustrate the concept. Once again thank you.
Attachments
PROBLEM STATEMENT.zip
(6.87 KiB) Downloaded 283 times
Post Reply