Hi all,
I am trying to figure out a way to have the value label of a variable (based on what is chosen) in the CAPI question. To be more specific I have a numerical variable in my application about GENDER , where GENDER takes 1.MALE 2.FEMALE. In the CAPI question following I want to include MALE or FEMALE. Right now if I use %GENDER% I will get 1 or 2 which is not what I would like to have. I know how to do when I want to have the names taken from the roster in question, but I could not find something that works in order to have the value label. Ideas anyone?
Best,
Stavros
value label in CAPI
Re: value label in CAPI
Hi all,
I managed to solve my issue. At the end it was quite easy. I created a string variable at the global procedure called Gender and I defined it at the postproc of GENDER. So for example
PROC GENDER
postproc
if GENDER = 1 then Gender = "MALE";
elseif GENDER = 1 then Gender="FEMALE";
endif;
After that I was able to use %Gender% in the CAPI question.
Best,
Stavros
I managed to solve my issue. At the end it was quite easy. I created a string variable at the global procedure called Gender and I defined it at the postproc of GENDER. So for example
PROC GENDER
postproc
if GENDER = 1 then Gender = "MALE";
elseif GENDER = 1 then Gender="FEMALE";
endif;
After that I was able to use %Gender% in the CAPI question.
Best,
Stavros
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: value label in CAPI
One way to do this, in a more generalizable way, is to use the getlabel function. This way, if you change the labels in your value set, they will automatically be reflected in your program. So you'd write something like this:
PROC GLOBAL
string genderText;
PROC GENDER
genderText = getlabel(GENDER,GENDER);
string genderText;
PROC GENDER
genderText = getlabel(GENDER,GENDER);