dummy variables from multiple categorical variables (DO REPEAT END REPEAT)

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

dummy variables from multiple categorical variables (DO REPEAT END REPEAT)

criscrostos-2
Hello community,

I am new to this but thought I would give it a shot since when looking form
an answer to my problem I came across the thread ‘creating dummy variables
from multiple categorical variables’ but that did not quite answer my
question.
My SPSS version: PASW Statistics 18. Release 18.0.0 (Jul 30, 2009)
What I want to do is to create several dummy variables from a set of 100+
variables (questions answers) that I have. The variables I have are numeric
nominals, of 6 categories. I want to merge those categories into 3.
(‘strongly agree’ & ‘agree’ into one, ‘strongly disagree’ & ‘disagree’ into
another, ‘don’t know’ into another, ‘neutral’ I will leave out). Essentially
what I want to get is a new set of variables with 3 categories instead of 6
as now. I will use to make basic graphs for now and not much other data
analysis.

I have variables named as follows:
q4_1 q4_2 q4_3 q4_4 q4_5 q4_6 q4_7 q4_8 q4_9 q4_10 q4_11 q4_12 q4_13 q4_14
q4_15 q4_16 q4_17
q6_1 q6_2 q6_3 q6_4 q6_5 q6_6 q6_7 q6_8 q6_9 q6_10 q6_11 q6_12 q6_13 q6_14
q6_15 q6_16 q6_17 q6_18 q6_19 q6_20 q6_21 q6_22
etc

I thought a loop would work best here, I am unsure how to enter my data to
create these new variables. The closest help I have come across is from the
two resources bellow yet I am still getting an error.

https://www.ibm.com/support/knowledgecenter/en/SSLVMB_24.0.0/spss/base/syn_do_repeat_examples.html
http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=search_page&node=1068821&query=dummy+variable+repeat&n=1068821 

What I have tried thus far with errors, for the set of question q4, from
q4_2 TO q4_17:

DO REPEAT existVar=q4_2 TO q4_17
/newVar=dum_q4 TO dum_q17
/value= (2=1) (6=1) (3=2) (7=2) (4=3)
EXECUTE.

/or/

VECTOR q4_2 (6,F1.0).
DO REPEAT Xn q4_2 TO q4_17 /#i = 2 TO 7.
  COMPUTE Xn = (X = #i).
END REPEAT.

Any guidance to a manual or other online resources will also be of much
help! The IBM’s  ‘Examples (DO REPEAT-END REPEAT command)’ are not offering
me much insight.


Thanks a lot in advance,

Cristina



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: dummy variables from multiple categorical variables (DO REPEAT END REPEAT)

Rich Ulrich
No, what you are doing is not "creating dummy variables" but rather
recoding the values.  Yes, you should put them into new variables. 
Look for RECODE.  Start with your proposed value-changes (though,
your ordering does not make sense for likert-type item-codes), 

RECODE  q4_1 to q4_17, q6_1 to q6_23 (1,2,6=1), (3,7=2),(4=3),
   (5=5)    /INTO= nq4_1 to nq4_17, nq6_1 to nq6_23) .

That code sets 1 to 1 and 5 to 5, values you had not accounted for.

Hope this helps. You should probably study the tutorials at UCLA or
elsewhere, soon.

--
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of criscrostos <[hidden email]>
Sent: Monday, July 6, 2020 3:57 PM
To: [hidden email] <[hidden email]>
Subject: dummy variables from multiple categorical variables (DO REPEAT END REPEAT)
 
Hello community,

I am new to this but thought I would give it a shot since when looking form
an answer to my problem I came across the thread ‘creating dummy variables
from multiple categorical variables’ but that did not quite answer my
question.
My SPSS version: PASW Statistics 18. Release 18.0.0 (Jul 30, 2009)
What I want to do is to create several dummy variables from a set of 100+
variables (questions answers) that I have. The variables I have are numeric
nominals, of 6 categories. I want to merge those categories into 3.
(‘strongly agree’ & ‘agree’ into one, ‘strongly disagree’ & ‘disagree’ into
another, ‘don’t know’ into another, ‘neutral’ I will leave out). Essentially
what I want to get is a new set of variables with 3 categories instead of 6
as now. I will use to make basic graphs for now and not much other data
analysis.

I have variables named as follows:
q4_1 q4_2 q4_3 q4_4 q4_5 q4_6 q4_7 q4_8 q4_9 q4_10 q4_11 q4_12 q4_13 q4_14
q4_15 q4_16 q4_17
q6_1 q6_2 q6_3 q6_4 q6_5 q6_6 q6_7 q6_8 q6_9 q6_10 q6_11 q6_12 q6_13 q6_14
q6_15 q6_16 q6_17 q6_18 q6_19 q6_20 q6_21 q6_22
etc

I thought a loop would work best here, I am unsure how to enter my data to
create these new variables. The closest help I have come across is from the
two resources bellow yet I am still getting an error.

https://www.ibm.com/support/knowledgecenter/en/SSLVMB_24.0.0/spss/base/syn_do_repeat_examples.html
<a href="http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=search_page&amp;node=1068821&amp;query=dummy&#43;variable&#43;repeat&amp;n=1068821">http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=search_page&node=1068821&query=dummy+variable+repeat&n=1068821

What I have tried thus far with errors, for the set of question q4, from
q4_2 TO q4_17:

DO REPEAT existVar=q4_2 TO q4_17
/newVar=dum_q4 TO dum_q17
/value= (2=1) (6=1) (3=2) (7=2) (4=3)
EXECUTE.

/or/

VECTOR q4_2 (6,F1.0).
DO REPEAT Xn q4_2 TO q4_17 /#i = 2 TO 7.
  COMPUTE Xn = (X = #i).
END REPEAT.

Any guidance to a manual or other online resources will also be of much
help! The IBM’s  ‘Examples (DO REPEAT-END REPEAT command)’ are not offering
me much insight.


Thanks a lot in advance,

Cristina



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: dummy variables from multiple categorical variables (DO REPEAT END REPEAT)

Art Kendall
In reply to this post by criscrostos-2
The usual purpose for creating a set of dummy variables is to enter a truly
nominal variable into some form of regression. Is this correct?

It appears that you are saying you want to coarsen a set of at-least-ordinal
variables so they have fewer values?  Is this correct? What is the context
for this?

Where did the set of variables come from?  Were they from previous studies
that used the questions as items in summative scales?  Is there a reason to
suspect that subsets of the variables measure something like an attitude or
personality variable?  Are there identical questions asked under different
times or conditions?

How many cases do you have?  This is important in terms of # of variables vs
# of cases.
What constitutes a case?

100+ questions!  

A lack of context makes this answer questionable. The literal answer might
well be something like this
RECODE /*OldVarList*/ (1,2=1) (3 =2) (4,5 =3) (6=-1) INTO /*NewVarList*/.
VALUE LABELS/ *NewVarlist*/
     1 'Strongly Disagree or Disagree'
     2 'Neutral'
     3 'Agree or Strongly Agree'
   -1 'Do not know'.
Missing Values /*NewVarList*/ (Lo thru -1).





-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Art Kendall
Social Research Consultants