Hi All
NEED YOUR HELP.
I created a questionnaire where some of the items is multiple (ABCD...) so i would like to separate them from each other and convert alphabet to numeric.
For example:
Old dictionary
Q36 = ABCD
New dictionary:
Q36A = 1
Q36B = 1
Q36C = 1
Q36D = 1
Q36E = 0
Something like this or the way how you understand it.
Thank you guys
Alpha to numeric
Re: Alpha to numeric
Hi Sharof,
Do you already have the data collected? Are you going to restructure the old data file to a new data file?
Anyways... This code should work.
Do you already have the data collected? Are you going to restructure the old data file to a new data file?
Anyways... This code should work.
Code: Select all
if pos ("A", Q36) then Q36A = 1; endif;
-
- Posts: 2
- Joined: October 20th, 2016, 12:40 am
Re: Alpha to numeric
Hi Saint,
Yes I'm going to restructure the old data file to new and also I used this way, but in new data file it doesn't changed.
I created the new dictionary same of old but in place of multiple answer (f.e. in item Q36 I have labels A B C X in old dict but in new I've just item Q36A with label of 1 and the same for B,C and X)
and the data file shows me that in Q36 = ACD know I need to divide it to Q36A = 1 Q36B = 1 Q36C = 1.
Yes I'm going to restructure the old data file to new and also I used this way, but in new data file it doesn't changed.
I created the new dictionary same of old but in place of multiple answer (f.e. in item Q36 I have labels A B C X in old dict but in new I've just item Q36A with label of 1 and the same for B,C and X)
and the data file shows me that in Q36 = ACD know I need to divide it to Q36A = 1 Q36B = 1 Q36C = 1.
Re: Alpha to numeric
Hi SharofNazar,
I think you can resolve your problem with the following code:
string zLst0 = "ABCDX",zlst1 = "ABCDE",zQ36 = "",zAns = "";
numeric x = length(zLst0),y;
do numeric i = 1 while i <= x
zAns = zLst0[i:1];
zQ36 = maketext("Q36%s",zlst1[i:1]);
y = 0;
if pos(zAns,Q36) > 0 then y = 1;endif;
setvalue(zQ36,y);
enddo;
I think you can resolve your problem with the following code:
string zLst0 = "ABCDX",zlst1 = "ABCDE",zQ36 = "",zAns = "";
numeric x = length(zLst0),y;
do numeric i = 1 while i <= x
zAns = zLst0[i:1];
zQ36 = maketext("Q36%s",zlst1[i:1]);
y = 0;
if pos(zAns,Q36) > 0 then y = 1;endif;
setvalue(zQ36,y);
enddo;