setocclabel()

Discussions about CSEntry
Post Reply
reeve
Posts: 17
Joined: July 29th, 2015, 9:55 am
Location: Washington, DC

setocclabel()

Post by reeve »

(in response to a topic "Restrict numbering" in "Other" about using names collected in an earlier roster module in subsequent rosters and questions.
josh wrote:Both approaches are possible.

To link them [names from an earlier roster for questions in a later module] via variable in one record that refers to the occurrence in the other record you can create a numeric variable that will contain the line number of the linked record. You can then use a dynamic value set (using setvalueset()) to have the interviewer pick the person whose line number you want to point to.

You can use the function setocclabel() to modify the labels of rows in a roster at runtime.
[ an earlier suggestion: "You can do this by using the name from the first module in the CAPI question text in the second module e.g. "Did %NAME% work last year".]

Yes these are exactly the 2 ways in which a capi interviewer needs access to a full household roster collected earlier in the survey. Either the 2nd question is asking "Who did x? Who was sick? etc." and needs the names from the earlier roster in a pop-up window from which to select the appropriate person and record his ID#. Or, the interviewer is going through the whole roster again for a question about each person and needs to know the appropriate name for each row.

So, I started with the second problem which seemed the easier (although less common). Using %NAME% in the question text is not too difficult as it requires no esoteric functions [but NAME supposedly comes from the first roster's question and is unlikely to be in the same roster/ form as for the 2nd roster's question so that requires a little programming to make sure a variable NAME is copied from the 1st roster question so it is available for the capi question in the 2nd roster/ form -- or at least I have not discovered how to get the 2nd roster's capi question to directly refer back to the NAME recorded in the 1st roster's answer].

The setocclabel() function looked easy enough and the otherwise cryptic help text promises that this is "especially useful when designing applications for Android devices" so the interviewer can see the names in the navigational tree rather than just (1) (2) etc. Really important for my interviewers. The help page describes:

"The setocclabel function sets the occurrence label for a repeating item or group (i.e., the row label of a roster)."

A little confusing since a repeating item has multiple row labels but the help description's "label" is in the singular. Either it really means label*s* and will set the labels for the entire series (who would want to change just one label?), or you have to invoke this function within a loop that changes each label sequentially. The example given is:

PROC PERSON_NAME
setocclabel(PERSON_FORM,maketext("Person %d: %s",curocc(),strip(PERSON_NAME)));

The first argument here is PERSON_FORM (form? is this the name of the form on which the roster is placed? or the name of the roster? and is that the second roster where you want the labels to show up or the first roster where the name was recorded? I am guessing the second roster and _FORM is just an unfortunate example of a roster name). The second argument, PERSON_NAME, sounds like a repeating item (seems like from the first roster because it has to already have been recorded to be used for labels in the second roster). In the example, neither PERSON_FORM nor PERSON_NAME are subscripted, so I hopefully guess that this will change all the row labels in the 2nd roster and I don't need a loop (while anxiously noting the "curocc()").

I seem to be guessing wrong. Several permutations of theses guesses all compile fine, but the row labels never change: 1,2,3,... I do get a warning:

W 8303 RO6_ROSTER should have a subscript - you may get error messages when you run this application

which suggests that the help example should have been subscripted too. But, if the first argument gets subscripted, RO6_ROSTER($) ?, that would seem to imply the setocclabel has to be embedded within a loop. But there is no loop in the example. Enough guesses for one day on this side of the world.

And next I have to tackle setvalueset().
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: setocclabel()

Post by josh »

Using a logic variable for the fill in the question text is the simplest way when the name variable is in a different roster from the field in which you want to use it. In CSPro 6.2 beta if both rosters come from the same record then CSPro will be smart to enough to use the proper occurrence number of the name variable in the second roster but I'm guessing that in your case you have them in different records in the dictionary so that wouldn't help.

That example for setocclabel in the help is quite misleading. Sorry about that.Take a look at the section on setting occurrence labels from logic in the following: http://teleyah.com/cspro/Lesotho/06-CAPI.pdf It has better examples.
Post Reply