recode/box statement help

Discussions about CSEntry
Post Reply
neel_ak47
Posts: 2
Joined: July 22nd, 2014, 7:53 am

recode/box statement help

Post by neel_ak47 »

Dear All,

I require help in putting recode statement correctly. Dependent out variable is string while all independent variables are numeric

My Code are following-

recode
Q1_BLID : Q2_VILLID :Q3_SRNO => Q6_TRAINEE_NAME;
1: 1: 1=>"Ram";
1: 1: 2=>"Shyam";
endrecode;

getting error"ERROR: Invalid variable type near line 3 in Q6_TRAINEE_NAME procedure"

Best Regards.
Neelanjana
manojsoni
Posts: 23
Joined: November 22nd, 2012, 11:55 pm
Location: Jaipur, India

Re: recode/box statement help

Post by manojsoni »

Hi Neelanjana

As alternate, you can use this code.

if q1_blid=1 and q2_villid=1 and q3_srno=1 then Q6_Trainee_Name="Ram"
elseif q1_blid=1 and q2_villid=1 and q3_srno=2 then Q6_Trainee_Name="Shyam";
endif;

Why it does not work with recode, probably our Gregory BOSS, may help us out.

Thanks
manoj
m9jiihmr@gmail.com
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: recode/box statement help

Post by Gregory Martin »

Neelanjana,

There is an error in the helps when it says that you can assign the output of a recode to an alpha variable. Right now you can only assign the output to a numeric variable. We will fix this so that in the next release, 6.0, you will be able to assign to an alpha variable. As Manoj indicated, you will have to use long form statements to achieve the recode:
if          Q1_BLID = 1 and Q2_VILLID = 1 and Q3_SRNO = 1 then Q6_TRAINEE_NAME = "Ram";
elseif      Q1_BLID = 1 and Q2_VILLID = 1 and Q3_SRNO = 2 then Q6_TRAINEE_NAME = "Shyam";
// elseif   ...
endif;
neel_ak47
Posts: 2
Joined: July 22nd, 2014, 7:53 am

Re: recode/box statement help

Post by neel_ak47 »

Thanks to both of you. as we have large database with name and other details many of them are in alpha ,I am using loadcases which is Ok.
Regards.
Neelanjana
Post Reply