Data recoding for multiple binary variables

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

Data recoding for multiple binary variables

Satish
Hi

I have list of 200 variables Q1 to Q200 where data is in binary format. if
answer is chosen its coded 1 if no than it is 0.

I would like to convert chosen code (which is 1) in respective code
(Variable name). how we can do it easily. Can we do it through vector or
loop function? pls help.

data is like

q1 q2 q3 q4 q5 q6
 1  1   1   1   1   1


and need to convert like

q1 q2 q3 q4 q5 q6
 1  2   3   4   5   6

Regards
Sat





--
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: Data recoding for multiple binary variables

David Marso-2
VECTOR q=q1 TO q200.
LOOP #=1 TO 200.
COMPUTE q(#)=#*q(#).
END LOOP.

=====================
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: Data recoding for multiple binary variables

Bruce Weaver
Administrator
In reply to this post by Satish
David has posted a nice solution.  But I am wondering why you want to do
this.  What is it you are ultimately trying to achieve?  There may be
another way.  Thanks for clarifying.  



Satish wrote

> Hi
>
> I have list of 200 variables Q1 to Q200 where data is in binary format. if
> answer is chosen its coded 1 if no than it is 0.
>
> I would like to convert chosen code (which is 1) in respective code
> (Variable name). how we can do it easily. Can we do it through vector or
> loop function? pls help.
>
> data is like
>
> q1 q2 q3 q4 q5 q6
>  1  1   1   1   1   1
>
>
> and need to convert like
>
> q1 q2 q3 q4 q5 q6
>  1  2   3   4   5   6
>
> Regards
> Sat
>
>
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: Data recoding for multiple binary variables

Jon Peck
In reply to this post by Satish
I am wondering whether you actually have a multiple response set coded as a set of dichotomies.  If so, you might, instead, define this set using the MRSETS command and analyze with CTABLES.

On Sat, Jul 6, 2019 at 3:35 PM Satish <[hidden email]> wrote:
Hi

I have list of 200 variables Q1 to Q200 where data is in binary format. if
answer is chosen its coded 1 if no than it is 0.

I would like to convert chosen code (which is 1) in respective code
(Variable name). how we can do it easily. Can we do it through vector or
loop function? pls help.

data is like

q1 q2 q3 q4 q5 q6
 1  1   1   1   1   1


and need to convert like

q1 q2 q3 q4 q5 q6
 1  2   3   4   5   6

Regards
Sat





--
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


--
Jon K Peck
[hidden email]

===================== 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: Data recoding for multiple binary variables

Rich Ulrich
Pushing Jon's question one step further...  I am curious
about what sort of question or analysis /wants/ to have
the "1" responses in form of the question number. 

When I see a string of answers that are "multiple responses"
that run, say, {1,2, 5, 9, ... 198} for the questions that were Yes,
I would either run mult-response or CTABLES.  For other sorts
of analyses or presentations, I think I would have to /convert/
them to the string of 0/1  numbers that you already have.

For curiousity's sake - What presentation or analysis is helped
by what you want to do?

--
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Saturday, July 6, 2019 5:58 PM
To: [hidden email]
Subject: Re: Data recoding for multiple binary variables
 
I am wondering whether you actually have a multiple response set coded as a set of dichotomies.  If so, you might, instead, define this set using the MRSETS command and analyze with CTABLES.

On Sat, Jul 6, 2019 at 3:35 PM Satish <[hidden email]> wrote:
Hi

I have list of 200 variables Q1 to Q200 where data is in binary format. if
answer is chosen its coded 1 if no than it is 0.

I would like to convert chosen code (which is 1) in respective code
(Variable name). how we can do it easily. Can we do it through vector or
loop function? pls help.

data is like

q1 q2 q3 q4 q5 q6
 1  1   1   1   1   1


and need to convert like

q1 q2 q3 q4 q5 q6
 1  2   3   4   5   6

Regards
Sat





--
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


--
Jon K Peck
[hidden email]

===================== 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: Data recoding for multiple binary variables

Satish
In reply to this post by David Marso-2
Hi David

Thanks helping me. its working fine.

Satish





--
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: Data recoding for multiple binary variables

Satish
This post was updated on .
In reply to this post by Rich Ulrich
Hi Rich Ulrich,

Yes, I am using CTABLES for running tables for these set of answer. Here is
the main reason to recode all binary data in to unique code.

I have a (Top of mind) question which is single response automobiles car
name where we have list of 200 cars starting from 1 to 200.

There is one more (spont awareness) question which is in binary (0,1) format
and there are 200 separate variable for each brand. For getting consolidated
data for TOM and SPONT i need to merge data of both question but it was not
possible run tables without re coding  binary data into UNIQUE CODE same as
TOM.

here is the the syntax for generating consolidate tables for TOM+SPONT


>> TOM  : Single Response question.

CTABLES
/VLABELS VARIABLES=Overall  DISPLAY= DEFAULT
/TABLE
Q7[C] [COLPCT.COUNT "Column %"F40.0,TOTALS[COUNT"Wtd Base"
F40.0,UCOUNT"Unwtd Base" F40.0 ]] BY
Overall[C]+zone[C]
/SLABELS POSITION=ROW
/CATEGORIES  VARIABLES=Q7 EMPTY=INCLUDE TOTAL=YES LABEL= "" POSITION= BEFORE
/CATEGORIES  VARIABLES=Overall EMPTY=INCLUDE TOTAL=No  LABEL= "Overall"
POSITION= BEFORE
/TITLES
   TITLE="Top of mind (TOM)"


>> SPONT : Multiple question.


MRSETS
/MDGROUP NAME =$Q7a LABEL ="" VARIABLES =Q7a_1 to Q7a_200 VALUE =1.
CTABLES
/VLABELS VARIABLES=Overall  DISPLAY= DEFAULT
/TABLE
$Q7a[C] [COLPCT.COUNT "Column %"F40.0,TOTALS[COUNT"Wtd Base"
F40.0,UCOUNT"Unwtd Base" F40.0 ]] BY
Overall[C]+zone[C]
/SLABELS POSITION=ROW
/CATEGORIES  VARIABLES=$Q7a EMPTY=INCLUDE TOTAL=YES LABEL= "" POSITION=
BEFORE
/CATEGORIES  VARIABLES=Overall EMPTY=INCLUDE TOTAL=No  LABEL= "Overall"
POSITION= BEFORE
/TITLES
   TITLE=" SPONT"


> TOM+SPONT AFTER RE CODIG BINARY VARIABLES OF SPONT IN TO UNIQUE CODE.


MRSETS
/MCGROUP NAME =$Q7a LABEL ="" VARIABLES =Q7 Q7a_1 to Q7a_200 VALUE =1.
CTABLES
/VLABELS VARIABLES=Overall  DISPLAY= DEFAULT
/TABLE
$Q7a[C] [COLPCT.COUNT "Column %"F40.0,TOTALS[COUNT"Wtd Base"
F40.0,UCOUNT"Unwtd Base" F40.0 ]] BY
Overall[C]+zone[C]
/SLABELS POSITION=ROW
/CATEGORIES  VARIABLES=$Q7a EMPTY=INCLUDE TOTAL=YES LABEL= "" POSITION=
BEFORE
/CATEGORIES  VARIABLES=Overall EMPTY=INCLUDE TOTAL=No  LABEL= "Overall"
POSITION= BEFORE
/TITLES
   TITLE="TOM+SPONT"

Please let me know if there is any shortcut method to generate consolidated
tables for single response question and multiple response question in binary
format.

Satish
 





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

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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: Data recoding for multiple binary variables

Jon Peck
I guess your current problem is solved, but for future similar work, you might want to consider using a multiple category set instead of a multiple dichotomy set.  Then, if you do need the multiple dichotomy form, you can use the STATS MCSET CONVERT extension command, available via Extensions > Extension Hub, to convert the MC set to an MD set.

On Tue, Jul 9, 2019 at 12:02 PM Satish <[hidden email]> wrote:
Hi Rich Ulrich,

Yes, I am using CTABLES for running tables for these set of answer. Here is
the main reason to recode all binary data in to unique code.

I have a (Top of mind) question which is single response automobiles car
name where we have list of 200 cars starting from 1 to 200.

There is one more (spont awareness) question which is in binary (0,1) format
and there are 200 separate variable for each brand. For getting consolidated
data for TOM and SPONT i need to merge data of both question but it was not
possible run tables without re coding  binary data into UNIQUE CODE same as
TOM.

here is the the syntax for generating consolidate tables for TOM+SPONT


>> TOM  : Single Response question.

CTABLES
/VLABELS VARIABLES=Overall  DISPLAY= DEFAULT
/TABLE
Q7[C] [COLPCT.COUNT "Column %"F40.0,TOTALS[COUNT"Wtd Base"
F40.0,UCOUNT"Unwtd Base" F40.0 ]] BY
Overall[C]+zone[C]
/SLABELS POSITION=ROW
/CATEGORIES  VARIABLES=Q7 EMPTY=INCLUDE TOTAL=YES LABEL= "" POSITION= BEFORE
/CATEGORIES  VARIABLES=Overall EMPTY=INCLUDE TOTAL=No  LABEL= "Overall"
POSITION= BEFORE
/TITLES
   TITLE="Top of mind (TOM)"


>> SPONT : Multiple question.


MRSETS
/MDGROUP NAME =$Q7a LABEL ="" VARIABLES =Q7a_1 to Q7a_200 VALUE =1.
CTABLES
/VLABELS VARIABLES=Overall  DISPLAY= DEFAULT
/TABLE
$Q7a[C] [COLPCT.COUNT "Column %"F40.0,TOTALS[COUNT"Wtd Base"
F40.0,UCOUNT"Unwtd Base" F40.0 ]] BY
Overall[C]+zone[C]+NDCity[C]+NDQ2[C]+$Ownership[C]+$BUYER_TYPE[C]
/SLABELS POSITION=ROW
/CATEGORIES  VARIABLES=$Q7a EMPTY=INCLUDE TOTAL=YES LABEL= "" POSITION=
BEFORE
/CATEGORIES  VARIABLES=Overall EMPTY=INCLUDE TOTAL=No  LABEL= "Overall"
POSITION= BEFORE
/TITLES
   TITLE=" SPONT"


> TOM+SPONT AFTER RE CODIG BINARY VARIABLES OF SPONT IN TO UNIQUE CODE.


MRSETS
/MCGROUP NAME =$Q7a LABEL ="" VARIABLES =Q7 Q7a_1 to Q7a_200 VALUE =1.
CTABLES
/VLABELS VARIABLES=Overall  DISPLAY= DEFAULT
/TABLE
$Q7a[C] [COLPCT.COUNT "Column %"F40.0,TOTALS[COUNT"Wtd Base"
F40.0,UCOUNT"Unwtd Base" F40.0 ]] BY
Overall[C]+zone[C]+NDCity[C]+NDQ2[C]+$Ownership[C]+$BUYER_TYPE[C]
/SLABELS POSITION=ROW
/CATEGORIES  VARIABLES=$Q7a EMPTY=INCLUDE TOTAL=YES LABEL= "" POSITION=
BEFORE
/CATEGORIES  VARIABLES=Overall EMPTY=INCLUDE TOTAL=No  LABEL= "Overall"
POSITION= BEFORE
/TITLES
   TITLE="TOM+SPONT"

Please let me know if there is any shortcut method to generate consolidated
tables for single response question and multiple response question in binary
format.

Satish






--
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


--
Jon K Peck
[hidden email]

===================== 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: Data recoding for multiple binary variables

Kirill Orlov
Converting multiple dichotomous set (MRD) to multiple categorical set (MRC) or back are also done by good old macros !MRDMRC and !MRCMRD found in collection "Categorical-Binary recodings" on my page

http://www.spsstools.net/en/KO-spssmacros



09.07.2019 22:04, Jon Peck пишет:
I guess your current problem is solved, but for future similar work, you might want to consider using a multiple category set instead of a multiple dichotomy set.  Then, if you do need the multiple dichotomy form, you can use the STATS MCSET CONVERT extension command, available via Extensions > Extension Hub, to convert the MC set to an MD set.


===================== 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: Data recoding for multiple binary variables

Jon Peck
I think it would be nice if these macros came with dialog box interfaces.  The dialog could even include the macro definition so that that did not have to be loaded separately.

On Tue, Jul 9, 2019 at 1:51 PM Kirill Orlov <[hidden email]> wrote:
Converting multiple dichotomous set (MRD) to multiple categorical set (MRC) or back are also done by good old macros !MRDMRC and !MRCMRD found in collection "Categorical-Binary recodings" on my page

http://www.spsstools.net/en/KO-spssmacros



09.07.2019 22:04, Jon Peck пишет:
I guess your current problem is solved, but for future similar work, you might want to consider using a multiple category set instead of a multiple dichotomy set.  Then, if you do need the multiple dichotomy form, you can use the STATS MCSET CONVERT extension command, available via Extensions > Extension Hub, to convert the MC set to an MD set.


===================== 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


--
Jon K Peck
[hidden email]

===================== 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