|
Can somebody help me with the following problem?
I have got a set of variables with different numbers of categories and I would like to find out all combinations of these variables/categories. Example: var1: 1="a" 2="b" 3="c" var2: 1="x" 2="y" var3: 1="z" 2=m" -> var12: 11="ax" 12="ay" 21="bx" 22="by" 31="cx" 32="cy" -> var13: 11="az" 21="bz" 31="cz" -> var23: 11="xz" 21="yz" -> var123:111="..." 211="..." 311 121 221 321 112 122 212 312 222 322 Has anybody got an idea? Kind regards, N. Knese |
|
Hi,
Try this: COMPUTE var12 = 10*var1+var2. COMPUTE var13 = 10*var1+var3. COMPÙTE var23 = 10*var2+var3. COMPUTE var123 = 100*var1+10*var2+var3. Greetings Frederic Frederic Villamayor, BS Researcher/Study Manager Biostatistics Unit Juan de Sada, 32 08028 Barcelona Tel +34 935093236 Fax +34 934112764 [hidden email] http://www.ferrergrupo.com Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede contener información confidencial, siendo para uso exclusivo del destinatario, quedando prohibida su divulgación, copia o distribución a terceros sin la autorización expresa del remitente. Si Vd. ha recibido este mensaje erróneamente, se ruega lo notifique al remitente y proceda a su borrado. Gracias por su colaboración. This message and its annexed files may contain confidential information which is exclusively for the use of the addressee. It is strictly forbidden to distribute copies to third parties without the explicit permission of the sender. If you receive this message by mistake, please notify it to the sender and make sure to delete it. Thank you for your kind cooperation. "N. Knese" <[hidden email]> Enviado por: "SPSSX(r) Discussion" <[hidden email]> 29/08/2007 12:19 Por favor, responda a "N. Knese" <[hidden email]> Para [hidden email] cc Asunto [SPSSX-L] All combinations of a set of variables Can somebody help me with the following problem? I have got a set of variables with different numbers of categories and I would like to find out all combinations of these variables/categories. Example: var1: 1="a" 2="b" 3="c" var2: 1="x" 2="y" var3: 1="z" 2=m" -> var12: 11="ax" 12="ay" 21="bx" 22="by" 31="cx" 32="cy" -> var13: 11="az" 21="bz" 31="cz" -> var23: 11="xz" 21="yz" -> var123:111="..." 211="..." 311 121 221 321 112 122 212 312 222 322 Has anybody got an idea? Kind regards, N. Knese |
|
In reply to this post by N. Knese
Hi!
Is there a possibility to put the combining itself into a macro/loop? I would like to call a macro and just give the variable names as parameters and the macro finds out all combinations and combines the variables/categories. It sounds so easy...but I have no idea ;-) Thanks. |
|
Sorry if this question has already been answered. Does anyone in here
know of a way to keep the data editor window from jumping around the desktop when any code is run? I work with several non-SPSS windows open simultaneously, and have to refer to several of them. However, when I run any syntax, the data editor simply relocates away from where it was, resizes itself to cover the other windows; (and I go "drat"!!!) Any help will be a huge relief! TIA Mike |
|
In reply to this post by N. Knese
At 06:19 AM 8/29/2007, N. Knese wrote:
>I have got a set of variables with different numbers of categories and >I >would like to find out all combinations of these variables/categories. > >Example: >var1: 1="a" 2="b" 3="c" >var2: 1="x" 2="y" >var3: 1="z" 2=m" > >-> var12: 11="ax" 12="ay" 21="bx" 22="by" 31="cx" 32="cy" >-> var13: 11="az" 21="bz" 31="cz" >-> var23: 11="xz" 21="yz" >-> var123:111="..." 211="..." 311 121 221 321 112 122 212 312 222 322 I'm not sure what you want. Do you want all these in one record (SPSS 'case'), or spread across multiple records? Usually the latter ('long' organization) is preferable, but you may have a reason for 'wide'. You do list 6 values for 'var12', which requires at least 6 records - a variable can't have more than one value in a record. Can you list a few *records* in your desired output? Or if you're thinking of one record only, can you tell us what you mean by >-> var12: 11="ax" 12="ay" 21="bx" 22="by" 31="cx" 32="cy" While I think of it: Is 'var12' a numeric or a string variable? It looks like it's numeric with value labels ("ax" being the value for numeric 11), but is that what you mean? (If it is, it'll be kind of complex code to generate it.) So, give us what more information you can. I hope these questions help clarify what we need. -Good luck, Richard |
| Free forum by Nabble | Edit this page |
