I'm a new user of SPSS 12 and i have a specific problem.
I've different nominal variables
Town var1 var2
BXl A B
Paris B D
...
i would like to have a new table where all the different forms of the
variables become a binary variable : like this
Town Var1A Var1B Var2B Var2D
BXL 1 0 1 0
Paris 0 1 0 1
I've try a script binarisation.sbs
(http://www.spss.com/fr/Downloads/Binarisation.SBS)
but i can't use it, it always says there's an error in the script...
Anybody can help me?
compute var1a = (var1 = 'A').
compute var1b = (var1 = 'B').
compute var2b = (var2 = 'B').
compute var2d = (var2 = 'D').
format var1a to var2d (f1.0).
list.
--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
Heeeelp.
You have also to know that i have in fact 50 variables with differents
answers who have all to become binary variables...
Thanks
Greg
I don't undestand why you have "<here>" in that compute statement. What
is it supposed to signify?
>
> Heeeelp.
>
> You have also to know that i have in fact 50 variables with differents
> answers who have all to become binary variables...
>
> Thanks
>
> Greg
IN that case, I think you'll want either a DO-REPEAT loop or a macro. I
won't try to write any code for that today, because I don't have SPSS at
home to test it.
I would be great if there is a script that can detect all the different
form of the variable and create a new binary one...
Like i said before the script binarisation should be able to do it...
but it doesn't... Even if i introduced all the values of the variable
in spss...
I can wait 'till monday, no problem... i'll look for the do-repeat
function
Thanks
Greg
if you have string variables try this macro:
define !BIN (!positional= !charend('|')
/LETT =!default (A) !charend ('|')
/nazwa=!default(new_) !charend('|') ).
!let !lista=!lett.
!do !j !in (!1).
!DO !I !IN (!lista).
!let !lette=!head(!lista).
!let !lista=!tail(!lista).
if (!j=!quote(!lette)) !concat(!j,'_',!lette)=1.
recode !concat(!j,'_',!lette) (sysmis=0).
!DOEND.
!let !lista=!lett.
!doend.
!enddefine.
!bin var1 var2 |lett =A B D.
if you have more letters then tree insert all of them into parametr
lett, fg. lett= A B C D E F
If you have more then two variables paste all of them after name of
macro fg. !bin var1 var2 var3 .... var50
Is it this what you want?
Lobin
gregius napisał(a):
> Hi,
>
> I'm a new user of SPSS 12 and i have a specific problem.
> I've different nominal variables
>
> Town var1 var2
> BXl A B
> Paris B D
> ....
Many thanks
Greg
lobin
gregius napisał(a):
> what are string variables?
> My variables are like this : profession (doctor, electrician,
> student...)
>