Hi, I have 2 variables var1 with value between 1 to 19 and var2 with value between 1 to 32. I want to generate the new variables with combination of var1 and var2 like var1_1_var2_1, var1_1_var2_2, var1_1_var2_3 , var1_1_var2_4, var1_1_var2_5 and so on Output is shown below Sno Var1 var2 var1_1_var2_1 var1_1_var2_2 var1_1_var2_3 var1_1_var2_4 var1_1_var2_5 var1_2_var2_2 var1_2_var2_5
var1_2_var2_19 1 1 4 1
2 1 2 1 3 1 3 1 4 2 2
1 5 2 5
1 6 2 19
1 Any help on this will be appreciated Thanks Manoj Kantar Disclaimer ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
Untested.
But you should be able to easily fix it if it doesn't work since the basic idea is utterly trivial. -- DEFINE !Whatever() !LET !List=" " !DO !V1=1 TO 19 !DO !V2=1 !TO 32 !LET !LIST=!CONCAT(!List,'var1_',!V1,'_var2_',!V2,' ') !DOEND !DOEND NUMERIC !List (F1). RECODE !List (ELSE=0). VECTOR Vars=!List . COMPUTE Vars((Var1-1)*19+Var2)=1. !ENDDEFINE . !Whatever .
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
Tested.
Found a few tiny bugs. Anybody spot them? DEFINE !Whatever () !LET !List=" " !DO !V1=1 !TO 19 !DO !V2=1 !TO 32 !LET !LIST=!CONCAT(!List,'var1_',!V1,'_var2_',!V2,' ') !DOEND !DOEND NUMERIC !List (F1). COMPUTE @=1. RECODE !List (ELSE=0). VECTOR Vars=Var1_1_Var2_1 TO @ . COMPUTE Vars((Var1-1)*32+Var2)=1. EXECUTE. DELETE VARIABLES @. !ENDDEFINE . DATA LIST FREE /Var1 Var2 . BEGIN DATA 1 1 1 7 2 9 2 10 3 19 19 32 END DATA. !Whatever .
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Manoj Arora (DEL/Abacus Analytics)
David answered about how t do this.
I am curious about WHY you want to do this.
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |