Hi there
I am a PhD student who is analyasing the survey data in SPSS. I have decided to collapse my multiple response question which starts from 1 to 16 into 4 separate categories,I am expecting one single Count for each category but still I have the answer from 1-16 and apparently they haven't been collapsed.I should add that all these data are recoded. I would be grateful if anyone could answer this question. Regards Mojdeh |
Dear All,
The following command applies only to numeric variables (i believe): Select if VAr > 0. exe. What is the equivalent for string variables? Sibusiso. |
In reply to this post by Mojdeh Jamnia
Mojdeh,
Without seeing your syntax it's hard to determine what you are doing, but perhaps you can use a DO IF-END IF statement. Maybe I am not understanding your issue...it has been known. :-) DO IF (oldvar LE 4). COMPUTE newvar=1. ELSE IF (oldvar GT 4 & oldvar LE 8). COMPUTE newvar=2. ELSE IF (oldvar GT 8 & oldvar LE 12). COMPUTE newvar=3. ELSE. COMPUTE newvar=4. END IF. EXE. If you want to do variable and value labels put the syntax before the "EXE" statement. Good luck. Dominic Dominic Lusinchi Statistician Far West Research Statistical Consulting San Francisco, California 415-664-3032 www.farwestresearch.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mojdeh Jamnia Sent: Tuesday, August 29, 2006 8:14 AM To: [hidden email] Subject: One question about multiple response Hi there I am a PhD student who is analyasing the survey data in SPSS. I have decided to collapse my multiple response question which starts from 1 to 16 into 4 separate categories,I am expecting one single Count for each category but still I have the answer from 1-16 and apparently they haven't been collapsed.I should add that all these data are recoded. I would be grateful if anyone could answer this question. Regards Mojdeh |
In reply to this post by Mojdeh Jamnia
Mojdeh,
**First recode the variables into 4 categories . ***** Here v1 to V6 was recoded into 4 categories , change classification to satisfy your needs . RECODE V1 TO V6 (1 THRU 4 =1) (5 THRU 9 =2) (9 THRU 12 =3) (13 THRU 16 = 4) INTO NV1 NV2 NV3 NV4 NV5 NV6 . EXECUTE. *****This syntax creates a multiple response set for the 4 categories . MRSETS /MCGROUP NAME=$Responses LABEL='Responses Provided' VARIABLES=NV1 NV2 NV3 NV4 NV5 NV6 /DISPLAY NAME=[$Responses]. Regards. Edward -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Mojdeh Jamnia Sent: Tuesday, August 29, 2006 11:14 AM To: [hidden email] Subject: One question about multiple response Hi there I am a PhD student who is analyasing the survey data in SPSS. I have decided to collapse my multiple response question which starts from 1 to 16 into 4 separate categories,I am expecting one single Count for each category but still I have the answer from 1-16 and apparently they haven't been collapsed.I should add that all these data are recoded. I would be grateful if anyone could answer this question. Regards Mojdeh |
In reply to this post by Mojdeh Jamnia
Sibusiso,
This should help: select if VAR>"VALUE". Vivek -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Sibusiso Moyo Sent: Tuesday, August 29, 2006 11:32 To: [hidden email] Subject: Re: Selecting non-missing cases in string variables Dear All, The following command applies only to numeric variables (i believe): Select if VAr > 0. exe. What is the equivalent for string variables? Sibusiso. |
In reply to this post by Mojdeh Jamnia
1. How did you collapse the variables in your multiple response set?
2. How do you know that they weren't collapsed. Which procedure or dialog box did you use to obtain the Count of categories? -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mojdeh Jamnia Sent: Tuesday, August 29, 2006 10:14 AM To: [hidden email] Subject: One question about multiple response Hi there I am a PhD student who is analyasing the survey data in SPSS. I have decided to collapse my multiple response question which starts from 1 to 16 into 4 separate categories,I am expecting one single Count for each category but still I have the answer from 1-16 and apparently they haven't been collapsed.I should add that all these data are recoded. I would be grateful if anyone could answer this question. Regards Mojdeh |
In reply to this post by Mojdeh Jamnia
Your subject heading contradicts what you want to do.
Supposing VAr is a string variable and you want to select non-missing cases in this variable then use the syntax below : SELECT IF (NOT MISSING(VAr)) . EXECUTE. Thanks. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Sibusiso Moyo Sent: Tuesday, August 29, 2006 11:32 AM To: [hidden email] Subject: Re: Selecting non-missing cases in string variables Dear All, The following command applies only to numeric variables (i believe): Select if VAr > 0. exe. What is the equivalent for string variables? Sibusiso. |
In reply to this post by Sibusiso Moyo
Hi Sibusiso
Concepts like greater or lower can't be applied to string variables, unless you are referring to text variables that contain only numbers (but that were read as strings). If you are talking about that, then try using NUMBER, like in this example: DATA LIST LIST/numstring(A1). BEGIN DATA 0 1 2 3 4 5 END DATA. LIST. TEMPORARY. SELECT IF NUMBER(numstring,F1) > 0. LIST. HTH, Marta SM> Dear All, SM> The following command applies only to numeric variables (i believe): Select if VAr >> 0. SM> exe. SM> What is the equivalent for string variables? |
In reply to this post by Edward Boadi
Hi Edward
You wrote: EB> Your subject heading contradicts what you want to do. EB> Supposing VAr is a string variable and you want to select EB> non-missing cases in this variable then EB> use the syntax below : EB> SELECT IF (NOT MISSING(VAr)) . EB> EXECUTE. (I hadn't read the subject heading, just the body message, now I understand a bit more Sibusiso's question). But... String variables don't have missing values. You must try something like this: DATA LIST LIST/stringvar(A16) numvar(F2). BEGIN DATA "" 1 "Not missing 1" 2 "Not missing 2" 3 "Not missing 3" 4 "Not missing 4" 5 "" 6 END DATA. LIST. TEMPORARY. SELECT IF LENGHT(RTRIM(stringvar)) NE 0. LIST. -- Regards, Marta |
In reply to this post by Edward Boadi
Thanks for the correction Marta
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Marta García-Granero Sent: Tuesday, August 29, 2006 11:54 AM To: [hidden email] Subject: Re: Selecting non-missing cases in string variables Hi Edward You wrote: EB> Your subject heading contradicts what you want to do. EB> Supposing VAr is a string variable and you want to select EB> non-missing cases in this variable then EB> use the syntax below : EB> SELECT IF (NOT MISSING(VAr)) . EB> EXECUTE. (I hadn't read the subject heading, just the body message, now I understand a bit more Sibusiso's question). But... String variables don't have missing values. You must try something like this: DATA LIST LIST/stringvar(A16) numvar(F2). BEGIN DATA "" 1 "Not missing 1" 2 "Not missing 2" 3 "Not missing 3" 4 "Not missing 4" 5 "" 6 END DATA. LIST. TEMPORARY. SELECT IF LENGHT(RTRIM(stringvar)) NE 0. LIST. -- Regards, Marta |
In reply to this post by Sibusiso Moyo
In the US, ASCII character order is used.
It is often useful to convert to lower or upper case before testing strings. There is example syntax below the sig block. Save all your current work, then open a new instance of SPSS. Make sure that you put warnings, etc. into the output file. <edit> <options> <viewer>. Cut-and-paste then run the syntax. Does this do what you want? If not please restate your question in more detail. Perhaps post a small data set with variables "have" and "want". Art Social Research Consultants data list list /x (a1) y (a1). begin data a A a b a B n m X x a ' ' ' ' 1 0 1 end data. compute islessthan = x lt y . list. Sibusiso Moyo wrote: >Dear All, > >The following command applies only to numeric variables (i believe): > >Select if VAr > 0. >exe. > >What is the equivalent for string variables? > >Sibusiso. > > > >
Art Kendall
Social Research Consultants |
In reply to this post by Marta García-Granero
A little clarification:
String variables do not have SYSMIS. String variables with length <=8 do support user missing, but not ranges. The MISSING function, unlike the other functions for missing values, may be used with either numeric or string variables in recent versions of SPSS. (I don't recall whether that was changed in 13 or 14.) Regards, Jon Peck SPSS -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero Sent: Tuesday, August 29, 2006 10:54 AM To: [hidden email] Subject: Re: [SPSSX-L] Selecting non-missing cases in string variables Hi Edward You wrote: EB> Your subject heading contradicts what you want to do. EB> Supposing VAr is a string variable and you want to select EB> non-missing cases in this variable then EB> use the syntax below : EB> SELECT IF (NOT MISSING(VAr)) . EB> EXECUTE. (I hadn't read the subject heading, just the body message, now I understand a bit more Sibusiso's question). But... String variables don't have missing values. You must try something like this: |
Hi Jon
"Thou shalt not forget thy children who dwell in darkness, far from the light of SPSS 14..." ;) I was thinking "elevenish", I didn't know that newer SPSS versions handled missing values in string variables (glad to hear that, makes my life as a teacher easier). I have just updated to SPSS 13 after a loooong time stuck with SPSS 11.5, and not a long time with SPSS 12 (and I should have been glad, since there still some computers with SPSS 10 at the University, things can go very slowly in some places). I stand corrected, thanks. Marta PJ> A little clarification: PJ> String variables do not have SYSMIS. PJ> String variables with length <=8 do support user missing, but not ranges. PJ> The MISSING function, unlike the other functions for missing PJ> values, may be used with either numeric or string variables in PJ> recent versions of SPSS. (I don't recall whether that was changed PJ> in 13 or 14.) |
In reply to this post by Edward Boadi
Dear All,
All I needed to do was select cases that have information. My string variable has information about types of a variable, so there is 21 of those types or so. So a case ought to have some form of variable type, and when that information is not there I needed to drop the case. Here is the physician list! 1 ALI 2 ALI CD 3 CD EM 4 EM END 5 END GE 6 GE ID 7 ID N 8 N NEP 9 NEP OBG 10 OBG ONC 11 ONC OPT 12 OPT ORS 13 ORS OTO 14 OTO PCP 15 PCP PED 16 PED PS 17 PS PSY 18 PSY PUD 19 PUD RHU 20 RHU URO 21 URO -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Marta García-Granero Sent: Tuesday, August 29, 2006 11:54 AM To: [hidden email] Subject: Re: Selecting non-missing cases in string variables Hi Edward You wrote: EB> Your subject heading contradicts what you want to do. EB> Supposing VAr is a string variable and you want to select EB> non-missing cases in this variable then EB> use the syntax below : EB> SELECT IF (NOT MISSING(VAr)) . EB> EXECUTE. (I hadn't read the subject heading, just the body message, now I understand a bit more Sibusiso's question). But... String variables don't have missing values. You must try something like this: DATA LIST LIST/stringvar(A16) numvar(F2). BEGIN DATA "" 1 "Not missing 1" 2 "Not missing 2" 3 "Not missing 3" 4 "Not missing 4" 5 "" 6 END DATA. LIST. TEMPORARY. SELECT IF LENGHT(RTRIM(stringvar)) NE 0. LIST. -- Regards, Marta |
Hi Sibusiyo
Since you don't mention the SPSS version you are using (nor the name of the string variable, I'll assume it is something like "physician"), just to make sure that it works, use: SELECT IF LENGHT(RTRIM(physician)) NE 0. This will eliminate unwanted cases. SM> All I needed to do was select cases that have information. My SM> string variable has information about types of a variable, so SM> there is 21 of those types or so. So a case ought to have some SM> form of variable type, and when that information is not there I SM> needed to drop the case. SM> Here is the physician list! SM> 1 SM> ALI 2 ALI SM> CD 3 CD SM> EM 4 EM SM> END 5 END SM> GE 6 GE SM> ID 7 ID SM> N 8 N SM> NEP 9 NEP SM> OBG 10 OBG SM> ONC 11 ONC SM> OPT 12 OPT SM> ORS 13 ORS SM> OTO 14 OTO SM> PCP 15 PCP SM> PED 16 PED SM> PS 17 PS SM> PSY 18 PSY SM> PUD 19 PUD SM> RHU 20 RHU SM> URO 21 URO Regards, Marta |
In reply to this post by Edward Boadi
I am using Version 14. I have actually used the following syntax, and it seemed to work:
Select if Cell ne (""). exe. Where Physician = Cell. Thanks for all your input. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Marta García-Granero Sent: Tuesday, August 29, 2006 1:54 PM To: [hidden email] Subject: Re: Selecting non-missing cases in string variables Hi Sibusiyo Since you don't mention the SPSS version you are using (nor the name of the string variable, I'll assume it is something like "physician"), just to make sure that it works, use: SELECT IF LENGHT(RTRIM(physician)) NE 0. This will eliminate unwanted cases. SM> All I needed to do was select cases that have information. My SM> string variable has information about types of a variable, so SM> there is 21 of those types or so. So a case ought to have some SM> form of variable type, and when that information is not there I SM> needed to drop the case. SM> Here is the physician list! SM> 1 SM> ALI 2 ALI SM> CD 3 CD SM> EM 4 EM SM> END 5 END SM> GE 6 GE SM> ID 7 ID SM> N 8 N SM> NEP 9 NEP SM> OBG 10 OBG SM> ONC 11 ONC SM> OPT 12 OPT SM> ORS 13 ORS SM> OTO 14 OTO SM> PCP 15 PCP SM> PED 16 PED SM> PS 17 PS SM> PSY 18 PSY SM> PUD 19 PUD SM> RHU 20 RHU SM> URO 21 URO Regards, Marta |
In reply to this post by Edward Boadi
Dear All,
I have about 13000 cases in my data set. I have these two variables that I am trying to test how close they are from each other. Specifically I am trying to identify cases, where the biggest difference arises. Besides taking differences between the two, sorting the data by the resulting difference variable, plots etc, would anyone have any ideas how one would proceed with such an assignment. Thanks, Sibusiso. |
In reply to this post by Marta García-Granero
Jon Peck of SPSS, Inc., had written
>>A little clarification: >>String variables do not have SYSMIS. >>String variables with length <=8 do support >>user missing, but not ranges. >>The MISSING function, unlike the other >>functions for missing values, may be used with >>either numeric or string variables in recent >>versions of SPSS. (I don't recall whether that >>was changed in 13 or 14.) At 01:16 PM 8/29/2006, Marta García-Granero wrote: >Hi Jon > >"Thou shalt not forget thy children who dwell in >darkness, far from the light of SPSS 14..." ;) > >I was thinking "elevenish", I didn't know that >newer SPSS versions handled missing values in string variables I think what Jon was saying was that the MISSING *function* started working with (short) string variables in 13 or 14. I believe that missing values have been supported for short string variables from back in the days where there was only mainframe SPSS. ('Short' is 8 or fewer characters.) Below is draft output run with SPSS 9. Now, second only to warnings not to use EXECUTE, I have suggestions for SPSS. Missing values for long strings would be VERY useful in one important case: to mask certain values from AGGREGATE. If you want only AGGREGATE to 'see' only values for cases that pass a certain test, with numbers and short strings, you can make other values missing (using TEMPORARY and RECODE, if that helps). There's no such recourse, for long strings. The best I know of, is to recode the values you don't want into something that compares lower than anything you do want (often, blank fits that criterion) and use the MAX function in AGGREGATE. Probably, the reason missing values are not supported for long strings, is that the dictionary data structure has 8 bytes, and only 8 bytes, for the values. But you could still allow missing values for long strings, accepting only 8-character values, and either, . Take a string as missing if its first 8 characters match the declared missing value, and the remainder of the string is blank . Take a string as missing if its first 8 characters match the declared missing value, regardless of the contents of the remaining characters. OK, off soapbox, and here's the test code. Again, this is SPSS 9, draft output. NEW FILE. DATA LIST FREE /STRING08(A08). BEGIN DATA Alpha Beta Gamma Delta Skip END DATA. STRING String12(A12). VARIABLE LABELS String08 "An 8-character string variable". VARIABLE LEVEL String08 (NOMINAL). VARIABLE ALIGNMENT String08(LEFT). VARIABLE LABELS String12 "The 12-character string variable". VARIABLE LEVEL String12 (NOMINAL). VARIABLE WIDTH String12(12). VARIABLE ALIGNMENT String12(LEFT). COMPUTE String12 = String08. LIST. List STRING08 STRING12 Alpha Alpha Beta Beta Gamma Gamma Delta Delta Skip Skip Number of cases read: 5 Number of cases listed: 5 * Here's the test: . Missing values STRING08 ('Skip'). VALUE LABELS String08 "Skip " "The missing value". Missing values STRING12('Skip'). >Error # 4808 in column 16. Text: STRING12 >Missing values are not available for long string variables. >This command not executed. VALUE LABELS String12 "Skip " "The missing value". >Warning # 4484. Command name: VALUE LABELS >The (ADD) VALUE LABELS command has attempted to apply a label to a variable >the values of which are long character strings. The variable will be >ignored. >The error is associated with 'STRING12' >Warning # 4487 in column 2. Text: Skip >The (ADD) VALUE LABELS command specifies the labeling of a value which is >inconsistent with the type of the variables to be labeled. The value and >the applicable label will be ignored. This error may occur because a >numeric value was omitted and the system mistook a label for a character >value. FREQUENCIES String08 String12. Frequencies Statistics |---------|------------------------------|--------------------------------| | |An 8-character string variable|The 12-character string variable| |-|-------|------------------------------|--------------------------------| |N|Valid |4 |5 | | |-------|------------------------------|--------------------------------| | |Missing|1 |0 | |-|-------|------------------------------|--------------------------------| ¢ Frequency Table An 8-character string variable |-------------------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-------|-----------------|---------|-------|-------------|------------------| |Valid |Alpha |1 |20.0 |25.0 |25.0 | | |-----------------|---------|-------|-------------|------------------| | |Beta |1 |20.0 |25.0 |50.0 | | |-----------------|---------|-------|-------------|------------------| | |Delta |1 |20.0 |25.0 |75.0 | | |-----------------|---------|-------|-------------|------------------| | |Gamma |1 |20.0 |25.0 |100.0 | | |-----------------|---------|-------|-------------|------------------| | |Total |4 |80.0 |100.0 | | |-------|-----------------|---------|-------|-------------|------------------| |Missing|The missing value|1 |20.0 | | | |-------|-----------------|---------|-------|-------------|------------------| |Total |5 |100.0 | | | |-------------------------|---------|-------|-------------|------------------| ¢ The 12-character string variable |-----------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-----|-----|---------|-------|-------------|------------------| |Valid|Alpha|1 |20.0 |20.0 |20.0 | | |-----|---------|-------|-------------|------------------| | |Beta |1 |20.0 |20.0 |40.0 | | |-----|---------|-------|-------------|------------------| | |Delta|1 |20.0 |20.0 |60.0 | | |-----|---------|-------|-------------|------------------| | |Gamma|1 |20.0 |20.0 |80.0 | | |-----|---------|-------|-------------|------------------| | |Skip |1 |20.0 |20.0 |100.0 | | |-----|---------|-------|-------------|------------------| | |Total|5 |100.0 |100.0 | | |-----|-----|---------|-------|-------------|------------------| |
In reply to this post by Sibusiso Moyo
(You posted with a blank subject heading; you probably know this, but
it makes reading and replying more difficult. I've put in a guess.) At 03:07 PM 8/29/2006, Sibusiso Moyo wrote: >I have about 13000 cases in my data set. I have these two variables >that I am trying to test how close they are from each other. >Specifically I am trying to identify cases, where the biggest >difference arises. Besides taking differences between the two, sorting >the data by the resulting difference variable, plots etc, would anyone >have any ideas how one would proceed with such an assignment. So, these are numeric variables? If they are strings, a crucial new question arises: how do you measure the 'difference' between two values. You list pretty much how anyone would start to do it. I'm not sure what plots you're doing - stem-and-leaf, to see something of the distribution of the differences? Is there any way in which what you're doing doesn't satisfy you? If so, say so, and maybe we'll have ideas. (I recommend new posts under the same subject heading "Re: [Differences in variable values]".) -Good luck, Richard Ristow |
Richard,
I thought I had a title in there. Apologies. Well I have two series of numeric data which I was hoping are similar/highly correlated/the same so I could use them interchangeably in my analysis. But I know that they are not because they come from different sources. So my initial take on them was to plot both series across time, to see how they vary. My second level of analysis was to take this data set and identify those particular cases that are giving us the most difference. With a large data set I didnt want to carry out this part manually, so I thought someone on the list might have done this before. I might have solved the problem for now though (i hope), Thanks for your input. Sibusiso. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Richard Ristow Sent: Tuesday, August 29, 2006 5:01 PM To: [hidden email] Subject: Re: [Differences in variable values] (You posted with a blank subject heading; you probably know this, but it makes reading and replying more difficult. I've put in a guess.) At 03:07 PM 8/29/2006, Sibusiso Moyo wrote: >I have about 13000 cases in my data set. I have these two variables >that I am trying to test how close they are from each other. >Specifically I am trying to identify cases, where the biggest >difference arises. Besides taking differences between the two, sorting >the data by the resulting difference variable, plots etc, would anyone >have any ideas how one would proceed with such an assignment. So, these are numeric variables? If they are strings, a crucial new question arises: how do you measure the 'difference' between two values. You list pretty much how anyone would start to do it. I'm not sure what plots you're doing - stem-and-leaf, to see something of the distribution of the differences? Is there any way in which what you're doing doesn't satisfy you? If so, say so, and maybe we'll have ideas. (I recommend new posts under the same subject heading "Re: [Differences in variable values]".) -Good luck, Richard Ristow |
Free forum by Nabble | Edit this page |