Alpha to numeric

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
SharofNazar
Posts: 2
Joined: October 20th, 2016, 12:40 am

Alpha to numeric

Post by SharofNazar »

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
Saint
Posts: 63
Joined: November 22nd, 2013, 4:59 am

Re: Alpha to numeric

Post by Saint »

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.

Code: Select all

if pos ("A", Q36) then Q36A = 1; endif;
SharofNazar
Posts: 2
Joined: October 20th, 2016, 12:40 am

Re: Alpha to numeric

Post by SharofNazar »

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.

:cry:
noel
Posts: 25
Joined: June 16th, 2012, 7:32 pm
Location: Libreville, Gabon

Re: Alpha to numeric

Post by noel »

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;
Post Reply