Dear Colleagues,
I am working on a data set where data for certain variables particularly those with multiple responses allowed are entered with " 1, 2, 3" for one variable. What I need to do is to split them into separate variables. For eg. current variable HPK001 - 1,2,3 I want to split it into 3 variables like - HPK001 - 1 HPK002 - 2 HPK003 - 3 The data are not consistent in one variable - some are 1,2 , some are 1,2,3,4 , some 1,2,3,4,5...etc. Much grateful if you kindly help me out. Many thanks in advance and looking forward to hearing from you. Regards, Khaing |
We need more detail on what your data actually look like. Meanwhile
check out MULT RESPONSE in the manual. From SPSS click on: Help >> Command Syntax Reference John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of khsoe Sent: 15 November 2016 12:25 To: [hidden email] Subject: How to split a variable Dear Colleagues, I am working on a data set where data for certain variables particularly those with multiple responses allowed are entered with " 1, 2, 3" for one variable. What I need to do is to split them into separate variables. For eg. current variable HPK001 - 1,2,3 I want to split it into 3 variables like - HPK001 - 1 HPK002 - 2 HPK003 - 3 The data are not consistent in one variable - some are 1,2 , some are 1,2,3,4 , some 1,2,3,4,5...etc. Much grateful if you kindly help me out. Many thanks in advance and looking forward to hearing from you. Regards, Khaing -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-split-a-variable- tp5733467.html Sent from the SPSSX Discussion mailing list archive at 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 |
In reply to this post by khsoe
If x is a variable holding a list of comma-separated numeric values, this code will produce separate variables with one value each. spssinc trans result=z1 to z10 /formula "re.split(',', x)". z1 to z10 are the variables to be produced. Change the upper limit (z10) as needed. The splitting pattern is the comma. It can be adjusted for more complicated patterns as needed. For cases where there are fewer than 10 values, the excess will be system missing. spssinc trans is an extension command that is normally installed with Statistics. Once you have these values, you can use Analyze > Tables > Multiple Response Sets to define the set and Custom Tables for analysis, assuming that you have the Custom Tables option. On Tue, Nov 15, 2016 at 4:24 AM, khsoe <[hidden email]> wrote: Dear Colleagues, |
Should the recode to a user missing value occur inside the Python code or should it be done after?
RECODE Z1 TO Z10 (SYSMIS = -1). MISSING VALUES Z1 TO Z10 (-1). VALUE LABELS Z1 TO z10 -1 'NOT USED' ... Of course 'Z' in the syntax snippet should be replaced by something meaningful to the OP.
Art Kendall
Social Research Consultants |
If the user wants labelled user-missing code, your syntax would be run after the spssinc trans code. Since it would be a regular Statistics transformation, it would piggy back on the next data pass, so there isn't any extra overhead from the RECODE. However, this data layout should be treated as a multiple-category set, not a multiple dichotomy, so there is no benefit in changing or labeling the missing values. In CTABLES, the actual values - 1, 2, 3, etc will label the output, and the unused slots will never appear. Run this code to see what I mean. MRSETS /MCGROUP NAME=$z VARIABLES=z1 z10 z2 z3 z4 z5 z6 z7 z8 z9. CTABLES /TABLE $z. On Tue, Nov 15, 2016 at 7:59 AM, Art Kendall <[hidden email]> wrote: Should the recode to a user missing value occur inside the Python code or |
One approach to quality assurance is to consider the data set "not yet ready for analysis" while there are system-missing values for variables.
In this instance the values are missing because the respondent did not use them. That is a known reason. In addition good practice is to have missing values labelled to aid in understanding the reasoning/meanings behind the analysis. CTABLES would be run after the variables view was reasonably completed. Of course without knowledge about the meaning of the valid values we cannot advise on the content of the other values, just that they should be labelled before running procedures.
Art Kendall
Social Research Consultants |
In Statistics, only GGRAPH and CTABLES handle multiple category sets of the modern kind (or MULT RESPONSE for the older type). These procedures always exclude sysmis values but allow inclusion of user missing values. But I don't think one would ever want to include missing values due to not having used up all the category slots, so sysmis is perfectly appropriate here. One should consider these variables as a set and think of the properties as belonging to the set. (Multiple dichotomies might have a use for user missing values.) It would be conceptually better to allow value labels to be attached at the set level for these as all slots (variables) should be consistent. In fact, the dialogs warn if there are any inconsistencies, and it is sufficient to define these for just one variable in the set. Of course, if the variables are strings, value labels may be redundant anyway, although they help with the displays in the CTABLES and GGRAPH canvases. On Tue, Nov 15, 2016 at 9:46 AM, Art Kendall <[hidden email]> wrote: One approach to quality assurance is to consider the data set "not yet ready |
In reply to this post by John F Hall
Hi Khaing,
I believe you are looking for something like this--you'll need to include enough Hval and newvar values to represent the highest values in your data. Since your examples had 1-5, that is what I used. do repeat Hval='1' '2' '3' '4' '5'/newvar=HPK1 HPK2 HPK3 HPK4 HPK5. Compute newvar=char.index(HPK001,HVal)>0. end repeat. HPK001 values entered... 1,2,3 1,2 1,2,3,4,5 4,5,1 2,4,1,3 5,4,2 4,1,2 Values created... HPK1 HPK2 HPK3 HPK4 HPK5 11100 11000 11111 10011 11110 01011 11010 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of khsoe Sent: 15 November 2016 12:25 To: [hidden email] Subject: How to split a variable Dear Colleagues, I am working on a data set where data for certain variables particularly those with multiple responses allowed are entered with " 1, 2, 3" for one variable. What I need to do is to split them into separate variables. For eg. current variable HPK001 - 1,2,3 I want to split it into 3 variables like - HPK001 - 1 HPK002 - 2 HPK003 - 3 The data are not consistent in one variable - some are 1,2 , some are 1,2,3,4 , some 1,2,3,4,5...etc. Much grateful if you kindly help me out. Many thanks in advance and looking forward to hearing from you. Regards, Khaing ===================== 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 ________________________________ This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== 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
|
Hi Melissa. I think you're going to run into trouble with that approach if double-digit numbers are possible. For example:
NEW FILE. DATASET CLOSE all. DATA LIST LIST / HPK001 (A10). BEGIN DATA "1,2,3" "1,2" "1,2,3,4,5" "4,5,1" "2,4,1,3" "5,4,2" "4,1,2" "2,5,10" END DATA. DO REPEAT Hval='1' '2' '3' '4' '5' '6' '7' '8' '9' '10' / newvar=HPK1 HPK2 HPK3 HPK4 HPK5 HPK6 HPK7 HPK8 HPK9 HPK10. - COMPUTE newvar=char.index(HPK001,HVal)>0. END REPEAT. FORMATS HPK1 to HPK10 (F1). LIST. HPK001 HPK1 HPK2 HPK3 HPK4 HPK5 HPK6 HPK7 HPK8 HPK9 HPK10 1,2,3 1 1 1 0 0 0 0 0 0 0 1,2 1 1 0 0 0 0 0 0 0 0 1,2,3,4,5 1 1 1 1 1 0 0 0 0 0 4,5,1 1 0 0 1 1 0 0 0 0 0 2,4,1,3 1 1 1 1 0 0 0 0 0 0 5,4,2 0 1 0 1 1 0 0 0 0 0 4,1,2 1 1 0 1 0 0 0 0 0 0 2,5,10 1 1 0 0 1 0 0 0 0 1 * Notice that for the last case, HPK1 is set to 1 by the * first digit in '10'. HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Bruce,
Truth. So much depends on what the data actually look like. Khaing, The ball is back in your court. Melissa Ives DMHAS Research Division 410 Capitol Ave., MS#14RSD Hartford, CT 06106 860-418-6729 (phone) 860-418-6692 (fax) 860-778-5445 (cell) ________________________________________ From: SPSSX(r) Discussion <[hidden email]> on behalf of Bruce Weaver <[hidden email]> Sent: Wednesday, November 16, 2016 2:48 PM To: [hidden email] Subject: Re: [SPSSX-L] How to split a variable Hi Melissa. I think you're going to run into trouble with that approach if double-digit numbers are possible. For example: NEW FILE. DATASET CLOSE all. DATA LIST LIST / HPK001 (A10). BEGIN DATA "1,2,3" "1,2" "1,2,3,4,5" "4,5,1" "2,4,1,3" "5,4,2" "4,1,2" "2,5,10" END DATA. DO REPEAT Hval='1' '2' '3' '4' '5' '6' '7' '8' '9' '10' / newvar=HPK1 HPK2 HPK3 HPK4 HPK5 HPK6 HPK7 HPK8 HPK9 HPK10. - COMPUTE newvar=char.index(HPK001,HVal)>0. END REPEAT. FORMATS HPK1 to HPK10 (F1). LIST. HPK001 HPK1 HPK2 HPK3 HPK4 HPK5 HPK6 HPK7 HPK8 HPK9 HPK10 1,2,3 1 1 1 0 0 0 0 0 0 0 1,2 1 1 0 0 0 0 0 0 0 0 1,2,3,4,5 1 1 1 1 1 0 0 0 0 0 4,5,1 1 0 0 1 1 0 0 0 0 0 2,4,1,3 1 1 1 1 0 0 0 0 0 0 5,4,2 0 1 0 1 1 0 0 0 0 0 4,1,2 1 1 0 1 0 0 0 0 0 0 2,5,10 1 1 0 0 1 0 0 0 0 1 * Notice that for the last case, HPK1 is set to 1 by the * first digit in '10'. HTH. Ives, Melissa L wrote > Hi Khaing, > > I believe you are looking for something like this--you'll need to include > enough Hval and newvar values to represent the highest values in your > data. Since your examples had 1-5, that is what I used. > > do repeat Hval='1' '2' '3' '4' '5'/newvar=HPK1 HPK2 HPK3 HPK4 HPK5. > Compute newvar=char.index(HPK001,HVal)>0. > end repeat. > > HPK001 values entered... > 1,2,3 > 1,2 > 1,2,3,4,5 > 4,5,1 > 2,4,1,3 > 5,4,2 > 4,1,2 > > Values created... > HPK1 HPK2 HPK3 HPK4 HPK5 > 11100 > 11000 > 11111 > 10011 > 11110 > 01011 > 11010 > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf > Of khsoe > Sent: 15 November 2016 12:25 > To: > SPSSX-L@.UGA > Subject: How to split a variable > > Dear Colleagues, > I am working on a data set where data for certain variables > particularly those with multiple responses allowed are entered with " > 1, 2, 3" for one variable. What I need to do is to split them into > separate variables. > > For eg. > current variable HPK001 - 1,2,3 > I want to split it into 3 variables like - HPK001 - 1 HPK002 - > 2 > HPK003 - 3 > The data are not consistent in one variable - some are 1,2 , some are > 1,2,3,4 , some 1,2,3,4,5...etc. > > Much grateful if you kindly help me out. Many thanks in advance and > looking forward to hearing from you. > Regards, > Khaing > > > ===================== > 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 > > ________________________________ > > This correspondence contains proprietary information some or all of which > may be legally privileged; it is for the intended recipient only. If you > are not the intended recipient you must not use, disclose, distribute, > copy, print, or rely on this correspondence and completely dispose of the > correspondence immediately. Please notify the sender if you have received > this email in error. NOTE: Messages to or from the State of Connecticut > domain may be subject to the Freedom of Information statutes and > regulations. > > ===================== > 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. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-split-a-variable-tp5733467p5733475.html Sent from the SPSSX Discussion mailing list archive at 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 ________________________________ This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== 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 |
Wow, I like this SPSSINC TRANS Extension Command!! Thanks, Mario "Ives, Melissa L" <[hidden email]> schrieb am 19:29 Dienstag, 29.November 2016: Bruce, Truth. So much depends on what the data actually look like. Khaing, The ball is back in your court. Melissa Ives DMHAS Research Division 410 Capitol Ave., MS#14RSD Hartford, CT 06106 860-418-6729 (phone) 860-418-6692 (fax) 860-778-5445 (cell) ________________________________________ From: SPSSX(r) Discussion <[hidden email]> on behalf of Bruce Weaver <[hidden email]> Sent: Wednesday, November 16, 2016 2:48 PM To: [hidden email] Subject: Re: [SPSSX-L] How to split a variable Hi Melissa. I think you're going to run into trouble with that approach if double-digit numbers are possible. For example: NEW FILE. DATASET CLOSE all. DATA LIST LIST / HPK001 (A10). BEGIN DATA "1,2,3" "1,2" "1,2,3,4,5" "4,5,1" "2,4,1,3" "5,4,2" "4,1,2" "2,5,10" END DATA. DO REPEAT Hval='1' '2' '3' '4' '5' '6' '7' '8' '9' '10' / newvar=HPK1 HPK2 HPK3 HPK4 HPK5 HPK6 HPK7 HPK8 HPK9 HPK10. - COMPUTE newvar=char.index(HPK001,HVal)>0. END REPEAT. FORMATS HPK1 to HPK10 (F1). LIST. HPK001 HPK1 HPK2 HPK3 HPK4 HPK5 HPK6 HPK7 HPK8 HPK9 HPK10 1,2,3 1 1 1 0 0 0 0 0 0 0 1,2 1 1 0 0 0 0 0 0 0 0 1,2,3,4,5 1 1 1 1 1 0 0 0 0 0 4,5,1 1 0 0 1 1 0 0 0 0 0 2,4,1,3 1 1 1 1 0 0 0 0 0 0 5,4,2 0 1 0 1 1 0 0 0 0 0 4,1,2 1 1 0 1 0 0 0 0 0 0 2,5,10 1 1 0 0 1 0 0 0 0 1 * Notice that for the last case, HPK1 is set to 1 by the * first digit in '10'. HTH. Ives, Melissa L wrote > Hi Khaing, > > I believe you are looking for something like this--you'll need to include > enough Hval and newvar values to represent the highest values in your > data. Since your examples had 1-5, that is what I used. > > do repeat Hval='1' '2' '3' '4' '5'/newvar=HPK1 HPK2 HPK3 HPK4 HPK5. > Compute newvar=char.index(HPK001,HVal)>0. > end repeat. > > HPK001 values entered... > 1,2,3 > 1,2 > 1,2,3,4,5 > 4,5,1 > 2,4,1,3 > 5,4,2 > 4,1,2 > > Values created... > HPK1 HPK2 HPK3 HPK4 HPK5 > 11100 > 11000 > 11111 > 10011 > 11110 > 01011 > 11010 > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > [hidden email] > ] On Behalf > Of khsoe > Sent: 15 November 2016 12:25 > To: > [hidden email] > Subject: How to split a variable > > Dear Colleagues, > I am working on a data set where data for certain variables > particularly those with multiple responses allowed are entered with " > 1, 2, 3" for one variable. What I need to do is to split them into > separate variables. > > For eg. > current variable HPK001 - 1,2,3 > I want to split it into 3 variables like - HPK001 - 1 HPK002 - > 2 > HPK003 - 3 > The data are not consistent in one variable - some are 1,2 , some are > 1,2,3,4 , some 1,2,3,4,5...etc. > > Much grateful if you kindly help me out. Many thanks in advance and > looking forward to hearing from you. > Regards, > Khaing > > > ===================== > 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 > > ________________________________ > > This correspondence contains proprietary information some or all of which > may be legally privileged; it is for the intended recipient only. If you > are not the intended recipient you must not use, disclose, distribute, > copy, print, or rely on this correspondence and completely dispose of the > correspondence immediately. Please notify the sender if you have received > this email in error. NOTE: Messages to or from the State of Connecticut > domain may be subject to the Freedom of Information statutes and > regulations. > > ===================== > 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 [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. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-split-a-variable-tp5733467p5733475.html Sent from the SPSSX Discussion mailing list archive at 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 ________________________________ This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== 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 |
Free forum by Nabble | Edit this page |