Multiple Responses to Categories

classic Classic list List threaded Threaded
6 messages Options
Tom
Reply | Threaded
Open this post in threaded view
|

Multiple Responses to Categories

Tom

 

Hello List

Sorry for this probably rather basic problem, which seems to be a common prerequisite to analyze multiple responses.  I’ve got multiple responses (7), which gave me seven dichotomous variables funkt1 to funkt7. As I checked the answers I figured out, that there have been chosen maximum three responses.

Now I’d like to compute 3 new variables newvar1 to newvar3 inserting a value according to the number of multiple response (1 to 7) with a positive response (value 1). My aim is to compute at the end one categorical variable, which contains the most frequent combinations of funkt1 to funkt7.

 

For instance:

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3

1             0             0             1             1             4

0             1             1             1             2             3             4

0             0             0             1             4

 

 

It looks like a loop and do if command?

Thanks for help!

Tom

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Responses to Categories

Maguin, Eugene

Certainly a loop structure.

 

Vector x=funkt1 to funkt7/y=newvar1 to newvar3.

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) y(#j)=#i.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

What is this part about ‘…one categorical variable, which contains the most frequent combinations…’? Don’t you then want a variable like ‘combo’ with values of

 

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3 combo

1             0             0             1             1             4                                                 14

0             1             1             1             2             3             4                                  234

0             0             0             1             4                                                                4

 

So would newvar1 to new3 are just be intermediates? If so, then why not this?

 

Vector x=funkt1 to funkt7.

String combo(a3).

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) substr(combo,#j,1)=1.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

Gene Maguin

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: Friday, June 22, 2012 4:03 AM
To: [hidden email]
Subject: Multiple Responses to Categories

 

 

Hello List

 

Sorry for this probably rather basic problem, which seems to be a common prerequisite to analyze multiple responses.  I’ve got multiple responses (7), which gave me seven dichotomous variables funkt1 to funkt7. As I checked the answers I figured out, that there have been chosen maximum three responses.

Now I’d like to compute 3 new variables newvar1 to newvar3 inserting a value according to the number of multiple response (1 to 7) with a positive response (value 1). My aim is to compute at the end one categorical variable, which contains the most frequent combinations of funkt1 to funkt7.

 

For instance:

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3

1             0             0             1             1             4

0             1             1             1             2             3             4

0             0             0             1             4

 

 

It looks like a loop and do if command?

Thanks for help!

Tom

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Responses to Categories

John F Hall
In reply to this post by Tom

Tom

 

There are two ways of dealing with this to start.

 

1:  Use MULT RESPONSE in dichotomous mode.

 

MULT RESPONSE groups difunkt (funkt1 to funkt7 (1))

/freq difunkt

/tab difunkt by difunkt .

 

and if you want the full three-way combinations add (in the last line)

 

[  /difunkt by difunkt by difunkt. ]

 

2:  Create seven new variables newfunkt1 to newfunkt7.

 

DO REPEAT x = funkt1 to funkt7

 /y = 1 to 7

/z = newfunkt1 to newfunkt7.

RECODE x (1=y) into z.

MULT RESPONSE groups mfunkt (newfunkt1 to newfunkt7 (1,7))

/tab mfunkt by mfunkt.

 

[  /tab mfunkt by mfunkt by mfunkt. ]

 

 

However (assuming all other values are zero and zero is not declared as missing) you can also create unique combinations of the seven binary codes

 

COMPUTE combfunkt = funkt1*1000000+funkt2*100000+funkt3+10000+funkt4*1000

               +funkt5*100+funkt6*10 + funkt7.

FREQ combfunkt.

 

By the same logic, you can produce a similar unique set of values using the recoded newfunkt~~~

 

COMPUTE combfunkt2 = newfunkt1*1000000+newfunkt2*100000+newfunkt3+10000+newfunkt4*1000

               +newfunkt5*100+newfunkt6*10 + newfunkt7.

FREQ combfunkt2.

 

I have a set of tutorials on multiple response on page http://surveyresearch.weebly.com/33-multiple-response-mult-response.html on my website and there’s an example from real surveys in the 3rd slide show on page http://surveyresearch.weebly.com/old-dog-old-tricks.html.

 

 

John F Hall (Mr)

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

 

 

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: 22 June 2012 10:03
To: [hidden email]
Subject: Multiple Responses to Categories

 

 

Hello List

 

Sorry for this probably rather basic problem, which seems to be a common prerequisite to analyze multiple responses.  I’ve got multiple responses (7), which gave me seven dichotomous variables funkt1 to funkt7. As I checked the answers I figured out, that there have been chosen maximum three responses.

Now I’d like to compute 3 new variables newvar1 to newvar3 inserting a value according to the number of multiple response (1 to 7) with a positive response (value 1). My aim is to compute at the end one categorical variable, which contains the most frequent combinations of funkt1 to funkt7.

 

For instance:

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3

1             0             0             1             1             4

0             1             1             1             2             3             4

0             0             0             1             4

 

 

It looks like a loop and do if command?

Thanks for help!

Tom

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Responses to Categories

David Marso
Administrator
In reply to this post by Tom
data list  /x1 to x7 (7F1).
begin data
1000010
0111000
1100000
1100001
0100011
0000010
0011000
0100010
end data.

COMPUTE ##=1.
COMPUTE COMB=0.
VECTOR X=X1 TO X7 / New(3).
LOOP #=1 TO 7.
+  DO IF X(#)=1.
+    COMPUTE New(##)=#.
+    COMPUTE Comb=Comb*10+#.
+    COMPUTE ##=##+1.
+  END IF.
END LOOP.
EXE.
FORMATS ALL (F3.0).
LIST.

 X1  X2  X3  X4  X5  X6  X7 COMB NEW1 NEW2 NEW3

  1   0   0   0   0   1   0   16    1    6    .
  0   1   1   1   0   0   0  234    2    3    4
  1   1   0   0   0   0   0   12    1    2    .
  1   1   0   0   0   0   1  127    1    2    7
  0   1   0   0   0   1   1  267    2    6    7
  0   0   0   0   0   1   0    6    6    .    .
  0   0   1   1   0   0   0   34    3    4    .
  0   1   0   0   0   1   0   26    2    6    .


Number of cases read:  8    Number of cases listed:  8
Balmer Thomas wrote
Hello List
Sorry for this probably rather basic problem, which seems to be a common prerequisite to analyze multiple responses.  I've got multiple responses (7), which gave me seven dichotomous variables funkt1 to funkt7. As I checked the answers I figured out, that there have been chosen maximum three responses.
Now I'd like to compute 3 new variables newvar1 to newvar3 inserting a value according to the number of multiple response (1 to 7) with a positive response (value 1). My aim is to compute at the end one categorical variable, which contains the most frequent combinations of funkt1 to funkt7.

For instance:
funkt1 funkt2 funkt3 funkt4 ... newvar1 newvar2 newvar3
1             0             0             1             1             4
0             1             1             1             2             3             4
0             0             0             1             4


It looks like a loop and do if command?
Thanks for help!
Tom
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?"
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Responses to Categories

Tom
In reply to this post by Tom

Yes, Gene, your second solution is exactly what I’m heading for: to find all these combinations.

But, trying your proposed syntax I got an error message (in German, sorry):

 

GET

  FILE='I:\...

DATASET NAME DatenSet1 WINDOW=FRONT.

Vector x=FunktionRLP to FunktionSL.

String combo(a3).

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) substr(combo,#j,1)=1.

 

Fehler Nr.  4309 in Spalte 1024.  Text: (Befehlsende)

Ungültige Kombination von Datentypen in einer Zuordnung.  Strings können nur

alphanumerischen Variablen zugeordnet werden.  Numerische und logische Werte

können nur numerischen Variablen zugeordnet werden.  Verwenden Sie die

Funktion STRING oder NUMBER.

Die Ausführung dieses Befehls wurde unterbrochen.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

…”invalid combination of Types of Data in an assignment. Strings can be assigned only to alphanumeric variables (…)”. I do not understand this problem. The Variables Funktion are numeric.…which shouldn’t be a problem?

 

 

@ John Hall: I also tried your syntax to combinate the 1 and 0 from all the funkt-variables, but it doesn’t seem to work, yet, and, actually, I’d prefer the combination as Gene proposed:

 

funkt1 funkt2 funkt3 funkt4 funkt5 funkt6 funkt7   comboJohn               correct                 comboGene

1     1     0     0     0     0     0     1110000     1100000     12

0     0     0     0     0     1     0     10010       0000010     6

1     1     0     0     0     0     0     1110000     1100000     12

0     0     1     0     0     0     1     10002       0010001     37

1     1     0     0     0     0     0     1110000     1100000     12

 

Tom

 

 

Von: SPSSX(r) Discussion [hidden email] Im Auftrag von Maguin, Eugene
Gesendet: Freitag, 22.
Juni 2012 14:17
An:
[hidden email]
Betreff: Re: Multiple Responses to Categories

 

Certainly a loop structure.

 

Vector x=funkt1 to funkt7/y=newvar1 to newvar3.

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) y(#j)=#i.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

What is this part about ‘…one categorical variable, which contains the most frequent combinations…’? Don’t you then want a variable like ‘combo’ with values of

 

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3 combo

1             0             0             1             1             4                                                 14

0             1             1             1             2             3             4                                  234

0             0             0             1             4                                                                4

 

So would newvar1 to new3 are just be intermediates? If so, then why not this?

 

Vector x=funkt1 to funkt7.

String combo(a3).

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) substr(combo,#j,1)=1.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

Gene Maguin

 

 

From: SPSSX(r) Discussion [hidden email] On Behalf Of Balmer, Thomas
Sent: Friday, June 22, 2012 4:03 AM
To: [hidden email]
Subject: Multiple Responses to Categories

 

 

Hello List

 

Sorry for this probably rather basic problem, which seems to be a common prerequisite to analyze multiple responses.  I’ve got multiple responses (7), which gave me seven dichotomous variables funkt1 to funkt7. As I checked the answers I figured out, that there have been chosen maximum three responses.

Now I’d like to compute 3 new variables newvar1 to newvar3 inserting a value according to the number of multiple response (1 to 7) with a positive response (value 1). My aim is to compute at the end one categorical variable, which contains the most frequent combinations of funkt1 to funkt7.

 

For instance:

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3

1             0             0             1             1             4

0             1             1             1             2             3             4

0             0             0             1             4

 

 

It looks like a loop and do if command?

Thanks for help!

Tom

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Responses to Categories

Maguin, Eugene

Thomas,

 

My apologies. This line

 

+  if (x(#i) eq 1) substr(combo,#j,1)=1.

 

Should be

 

+  if (x(#i) eq 1) substr(combo,#j,1)=’1’.

 

Gene Maguin

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: Monday, June 25, 2012 5:41 AM
To: [hidden email]
Subject: Re: Multiple Responses to Categories

 

Yes, Gene, your second solution is exactly what I’m heading for: to find all these combinations.

But, trying your proposed syntax I got an error message (in German, sorry):

 

GET

  FILE='I:\...

DATASET NAME DatenSet1 WINDOW=FRONT.

Vector x=FunktionRLP to FunktionSL.

String combo(a3).

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) substr(combo,#j,1)=1.

 

Fehler Nr.  4309 in Spalte 1024.  Text: (Befehlsende)

Ungültige Kombination von Datentypen in einer Zuordnung.  Strings können nur

alphanumerischen Variablen zugeordnet werden.  Numerische und logische Werte

können nur numerischen Variablen zugeordnet werden.  Verwenden Sie die

Funktion STRING oder NUMBER.

Die Ausführung dieses Befehls wurde unterbrochen.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

…”invalid combination of Types of Data in an assignment. Strings can be assigned only to alphanumeric variables (…)”. I do not understand this problem. The Variables Funktion are numeric.…which shouldn’t be a problem?

 

 

@ John Hall: I also tried your syntax to combinate the 1 and 0 from all the funkt-variables, but it doesn’t seem to work, yet, and, actually, I’d prefer the combination as Gene proposed:

 

funkt1 funkt2 funkt3 funkt4 funkt5 funkt6 funkt7   comboJohn               correct                 comboGene

1     1     0     0     0     0     0     1110000     1100000     12

0     0     0     0     0     1     0     10010       0000010     6

1     1     0     0     0     0     0     1110000     1100000     12

0     0     1     0     0     0     1     10002       0010001     37

1     1     0     0     0     0     0     1110000     1100000     12

 

Tom

 

 

Von: SPSSX(r) Discussion [hidden email] Im Auftrag von Maguin, Eugene
Gesendet: Freitag, 22.
Juni 2012 14:17
An:
[hidden email]
Betreff: Re: Multiple Responses to Categories

 

Certainly a loop structure.

 

Vector x=funkt1 to funkt7/y=newvar1 to newvar3.

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) y(#j)=#i.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

What is this part about ‘…one categorical variable, which contains the most frequent combinations…’? Don’t you then want a variable like ‘combo’ with values of

 

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3 combo

1             0             0             1             1             4                                                 14

0             1             1             1             2             3             4                                  234

0             0             0             1             4                                                                4

 

So would newvar1 to new3 are just be intermediates? If so, then why not this?

 

Vector x=funkt1 to funkt7.

String combo(a3).

Compute #j=1.

Loop #i=1 to 7.

+  if (x(#i) eq 1) substr(combo,#j,1)=1.

+  if (x(#i) eq 1) #j=#j+1.

End loop.

 

Gene Maguin

 

 

From: SPSSX(r) Discussion [hidden email] On Behalf Of Balmer, Thomas
Sent: Friday, June 22, 2012 4:03 AM
To: [hidden email]
Subject: Multiple Responses to Categories

 

 

Hello List

 

Sorry for this probably rather basic problem, which seems to be a common prerequisite to analyze multiple responses.  I’ve got multiple responses (7), which gave me seven dichotomous variables funkt1 to funkt7. As I checked the answers I figured out, that there have been chosen maximum three responses.

Now I’d like to compute 3 new variables newvar1 to newvar3 inserting a value according to the number of multiple response (1 to 7) with a positive response (value 1). My aim is to compute at the end one categorical variable, which contains the most frequent combinations of funkt1 to funkt7.

 

For instance:

funkt1 funkt2 funkt3 funkt4 … newvar1 newvar2 newvar3

1             0             0             1             1             4

0             1             1             1             2             3             4

0             0             0             1             4

 

 

It looks like a loop and do if command?

Thanks for help!

Tom