|
Hello,
I found your group as I was trying to figure out how to recode system missing dates into a certain date in SPSS. I tried these syntax codes but did not work: recode interviewdate sysmis=("09,09,1996"). recode interviewdate sysmis=(date.mdy(09,09,1996)). I would appreciate if anyone could help me on this. Thank you, Asil Asil Ali Özdoğru Research Associate Policy Research Associates 345 Delaware Avenue Delmar, NY 12054 Ph: (518) 439-7415 x 364 Fax: (518).439-7612 [hidden email]<mailto:[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 |
|
At 11:58 AM 6/10/2008, Asil Ozdogru wrote:
>I was trying to figure out how to recode system missing dates into a >certain date in SPSS. There have been, I think, some enhancements to make RECODE easier to use with dates, but I can't find documentation, at the moment. In the meantime, this should work: IF SYSMIS(interviewdate) interviewdate = date.mdy(09,09,1996). There is Python code on Developer Central to create RECODEs that work for date variables (see Jon Peck's note, reproduced at the end of this one), but I'm not sure whether that helps you specify dates as target values. > I tried these syntax codes but did not work: >recode interviewdate sysmis=("09,09,1996"). >recode interviewdate sysmis=(date.mdy(09,09,1996)). First, simply as recode specifications, these are syntactically invalid. The whole specification (source value, '=', target value) need to be within the parentheses; i.e. the left parenthesis must come *before* "sysmis". Like this, but these still won't work: recode interviewdate (sysmis="09,09,1996"). recode interviewdate (sysmis=date.mdy(09,09,1996)). The first won't work because the target "09,09,1996" is a string value, not a date. And the second won't because, although 'date.mdy(09,09,1996)' evaluates to a valid date value, it's an expression, and RECODE targets can only be constants. ................ Date: Thu, 21 Feb 2008 20:13:49 -0600 From: "Peck, Jon" <[hidden email]> Subject: Re: seeking help with date variables To: [hidden email] One of our Python supplementary modules handles date notation for recodes. It also creates value labels for the recoded variable automatically. Here is an example. The code below recodes the date variable bdate (in employee data.sav) into bdaterecode. It takes a dictionary of values to recode. So, for example, the date 1952-02-03 is recoded into the value 100. The generate line executes the commands, but it also returns the syntax for the Recode and for generating value labels for the recoded data in case that is wanted for other reasons. begin program. import spss, specialtransforms rec = specialtransforms.Recode("bdaterecode", "bdate", {'1952-02-03': 100, '1958-05-23':200}, inputtype='D', elserc=300) syntax = rec.generate(execute=True) print syntax end program. The syntax printed would be NUMERIC bdaterecode (F8.0). RECODE bdate (11654150400=100) (11852956800=200) (ELSE=300) INTO bdaterecode. VALUE LABELS bdaterecode 200 "1958-05-23" 100 "1952-02-03". This requires at least SPSS 14.0.1, the Python plugin, and the specialtransforms module, the latter two from SPSS Developer Central (www.spss.com/devcentral). That didn't work (and probably gave you an error message) because "09,09,1996" is a character string, not a date value, and you can't recode a numeric into a character string. And this won't work because a RECODE ===================== 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 |
|
Hello,
Can someone tell me how I can modify a set of data from one format to another please? I have a string variable and want to get rid of fist three characters (e.g., ABC12345 to 12345). Thanks, Asil Asil Ali Özdoğru Research Associate Policy Research Associates 345 Delaware Avenue Delmar, NY 12054 Ph: (518) 439-7415 x 364 Fax: (518).439-7612 [hidden email] -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Tuesday, June 10, 2008 9:56 PM To: Asil Ozdogru; [hidden email] Cc: Peck, Jon Subject: Re: Missing dates? At 11:58 AM 6/10/2008, Asil Ozdogru wrote: >I was trying to figure out how to recode system missing dates into a >certain date in SPSS. There have been, I think, some enhancements to make RECODE easier to use with dates, but I can't find documentation, at the moment. In the meantime, this should work: IF SYSMIS(interviewdate) interviewdate = date.mdy(09,09,1996). There is Python code on Developer Central to create RECODEs that work for date variables (see Jon Peck's note, reproduced at the end of this one), but I'm not sure whether that helps you specify dates as target values. > I tried these syntax codes but did not work: >recode interviewdate sysmis=("09,09,1996"). >recode interviewdate sysmis=(date.mdy(09,09,1996)). First, simply as recode specifications, these are syntactically invalid. The whole specification (source value, '=', target value) need to be within the parentheses; i.e. the left parenthesis must come *before* "sysmis". Like this, but these still won't work: recode interviewdate (sysmis="09,09,1996"). recode interviewdate (sysmis=date.mdy(09,09,1996)). The first won't work because the target "09,09,1996" is a string value, not a date. And the second won't because, although 'date.mdy(09,09,1996)' evaluates to a valid date value, it's an expression, and RECODE targets can only be constants. ................ Date: Thu, 21 Feb 2008 20:13:49 -0600 From: "Peck, Jon" <[hidden email]> Subject: Re: seeking help with date variables To: [hidden email] One of our Python supplementary modules handles date notation for recodes. It also creates value labels for the recoded variable automatically. Here is an example. The code below recodes the date variable bdate (in employee data.sav) into bdaterecode. It takes a dictionary of values to recode. So, for example, the date 1952-02-03 is recoded into the value 100. The generate line executes the commands, but it also returns the syntax for the Recode and for generating value labels for the recoded data in case that is wanted for other reasons. begin program. import spss, specialtransforms rec = specialtransforms.Recode("bdaterecode", "bdate", {'1952-02-03': 100, '1958-05-23':200}, inputtype='D', elserc=300) syntax = rec.generate(execute=True) print syntax end program. The syntax printed would be NUMERIC bdaterecode (F8.0). RECODE bdate (11654150400=100) (11852956800=200) (ELSE=300) INTO bdaterecode. VALUE LABELS bdaterecode 200 "1958-05-23" 100 "1952-02-03". This requires at least SPSS 14.0.1, the Python plugin, and the specialtransforms module, the latter two from SPSS Developer Central (www.spss.com/devcentral). That didn't work (and probably gave you an error message) because "09,09,1996" is a character string, not a date value, and you can't recode a numeric into a character string. And this won't work because a RECODE ===================== 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 |
|
At 05:15 PM 6/17/2008, Asil Ozdogru wrote:
>I have a string variable and want to get rid of fist three >characters (e.g., ABC12345 to 12345). Well, if that's all you want, there's this (not tested). Notice that I'm creating a new variable for the shortened string. You NEVER want to throw away information from an original variable. STRING NewString (A8). COMPUTE NewString = SUBSTR(OldString,4). ===================== 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 |
|
At 03:59 PM 6/19/2008, Asil Ozdogru wrote, off-list:
>I have this string variable holding parts of two dates ("08290621" = >08/29 06/21). How can I calculate the difference in days between >these two dates buried in this string variable? For reasons I've given, I'll almost never answer questions posed to me off-list. However, sometimes I'll take one on-list, if it seems of general interest. The solution to a problem involving dates in SPSS is, almost always, to make the dates SPSS date values. Now, an SPSS date is a specific day in a specific year. You have only month and day. I'm arbitrarily putting your dates in 2001-2002, and assuming that all intervals are positive and no more than one year. There's an ambiguity: February sometimes has 28 days, sometimes 29. In this calculation, both Februaries have 28 days. |-----------------------------|---------------------------| |Output Created |19-JUN-2008 18:42:17 | |-----------------------------|---------------------------| StrDates 08290621 01150227 02051210 Number of cases read: 3 Number of cases listed: 3 * In pursuit of readability, this solution is very . * generous in its use of scratch variables and lines . * of code. . STRING #Dt1Str #Dt2Str (A4). STRING #Mo1Str #Dy1Str #Mo2Str #Dy2Str (A2). NUMERIC #Mo1 #Dy1 #Mo2 #Dy2 (F2). * Could change to '#Date1', '#Date2', so the dates . * would not appear in the output file. . NUMERIC @Date1 @Date2 (DATE11). * Break up the input string into the two dates -- . COMPUTE #Dt1Str = SUBSTR(StrDates,1,4). COMPUTE #Dt2Str = SUBSTR(StrDates,5,4). DO REPEAT DateStr = #Dt1Str #Dt2Str /MonStr = #Mo1Str #Mo2Str /DayStr = #Dy1Str #Dy2Str /Mon = #Mo1 #Mo2 /Day = #Dy1 #Dy2 /Date = @Date1 @Date2. * -- then, each date into month and year as strings -- . . COMPUTE MonStr = SUBSTR(DateStr,1,2). . COMPUTE DayStr = SUBSTR(DateStr,3,2). * -- then, month and year as numbers -- . . COMPUTE Mon = NUMBER(MonStr,F2). . COMPUTE Day = NUMBER(DayStr,F2). * -- and finally, SPSS dates, arbitrarily in 2001. . . COMPUTE Date = DATE.MDY(Mon,Day,2001). END REPEAT. * Move the second date into 2002, if necessary to make . * the interval a positive number of days . IF @Date2 LE @Date1 @Date2 = DATE.MDY(#Mo2,#Dy2,2002). * Compute the difference, in days . NUMERIC DaysBtwn (F4). COMPUTE DaysBtwn=CTIME.DAYS(@Date2-@Date1). LIST. List |-----------------------------|---------------------------| |Output Created |19-JUN-2008 18:42:18 | |-----------------------------|---------------------------| StrDates @Date1 @Date2 DaysBtwn 08290621 29-AUG-2001 21-JUN-2002 296 01150227 15-JAN-2001 27-FEB-2001 43 02051210 05-FEB-2001 10-DEC-2001 308 Number of cases read: 3 Number of cases listed: 3 ======================= APPENDIX: Data and code ======================= DATA LIST FREE / StrDates (A8). BEGIN DATA 08290621 01150227 02051210 END DATA. LIST. * In pursuit of readability, this solution is very . * generous in its use of scratch variables and lines . * of code. . STRING #Dt1Str #Dt2Str (A4). STRING #Mo1Str #Dy1Str #Mo2Str #Dy2Str (A2). NUMERIC #Mo1 #Dy1 #Mo2 #Dy2 (F2). * Could change to '#Date1', '#Date2', so the dates . * would not appear in the output file. . NUMERIC @Date1 @Date2 (DATE11). * Break up the input string into the two dates -- . COMPUTE #Dt1Str = SUBSTR(StrDates,1,4). COMPUTE #Dt2Str = SUBSTR(StrDates,5,4). DO REPEAT DateStr = #Dt1Str #Dt2Str /MonStr = #Mo1Str #Mo2Str /DayStr = #Dy1Str #Dy2Str /Mon = #Mo1 #Mo2 /Day = #Dy1 #Dy2 /Date = @Date1 @Date2. * -- then, each date into month and year as strings -- . . COMPUTE MonStr = SUBSTR(DateStr,1,2). . COMPUTE DayStr = SUBSTR(DateStr,3,2). * -- then, month and year as numbers -- . . COMPUTE Mon = NUMBER(MonStr,F2). . COMPUTE Day = NUMBER(DayStr,F2). * -- and finally, SPSS dates, arbitrarily in 2001. . . COMPUTE Date = DATE.MDY(Mon,Day,2001). END REPEAT. * Move the second date into 2002, if necessary to make . * the interval a positive number of days . IF @Date2 LE @Date1 @Date2 = DATE.MDY(#Mo2,#Dy2,2002). * Compute the difference, in days . NUMERIC DaysBtwn (F4). COMPUTE DaysBtwn=CTIME.DAYS(@Date2-@Date1). LIST. ===================== 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 |
|
Hello everyone,
My colleague and I were working on the same SPSS file that I created in version 13. She has version 12 and I have 13 on our machines. After one point when she added some data to the file from a data file in version 12, data started to look weird and unreadable in my computer but looks fine in her computer. Is this a version issue or what? And how can we get over it? Thanks, Asil ===================== 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 |
|
The data file characteristics haven't changed in SPSS so something else is
at issue here? WMB Statistical Services ============ mailto: [hidden email] http:\\home.earthlink.net\~statmanz ============ On 8/12/2008 1:12:19 PM, [hidden email] wrote: > Hello everyone, > > My colleague and I were working on the same SPSS file that I created in > version 13. She has version 12 and I have 13 on our machines. After one > point when she added some data to the file from a data file in version 12, > data started to look weird and unreadable in my computer but looks fine in > her computer. Is this a version issue or what? And how can we get over > it? > > Thanks, > > Asil > > ===================== > 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
Will
Statistical Services ============ info.statman@earthlink.net http://home.earthlink.net/~z_statman/ ============ |
|
The maximum length of string variables was increased from 255 bytes to 32,767 bytes in SPSS 13. IIRC, when an SPSS 13 data file with a string variable over 255 bytes is opened in SPSS 12, the variable should get split into multiple variables.
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Statmanz Sent: Tuesday, August 12, 2008 2:43 PM To: [hidden email] Subject: Re: Version issue? The data file characteristics haven't changed in SPSS so something else is at issue here? WMB Statistical Services ============ mailto: [hidden email] http:\\home.earthlink.net\~statmanz ============ On 8/12/2008 1:12:19 PM, [hidden email] wrote: > Hello everyone, > > My colleague and I were working on the same SPSS file that I created in > version 13. She has version 12 and I have 13 on our machines. After one > point when she added some data to the file from a data file in version 12, > data started to look weird and unreadable in my computer but looks fine in > her computer. Is this a version issue or what? And how can we get over > it? > > Thanks, > > Asil > > ===================== > 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 ===================== 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 zstatman
Hello,
How can I split a string variable (name) that holds both last and first name (Ozdogru, Asil) into two variables for last (lname) and first name (fname)? Thanks, Asil ===================== 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 |
|
Asil,
I assume every value of name is structured as lastname, firstname. I assume name is A40. String fname lname(a20). #i=index(name,','). Compute lname=substr(name,1,#i-1). Compute fname=substr(name,#i+2,40-#i+1). Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Asil Ozdogru Sent: Tuesday, October 07, 2008 3:58 PM To: [hidden email] Subject: Splitting names Hello, How can I split a string variable (name) that holds both last and first name (Ozdogru, Asil) into two variables for last (lname) and first name (fname)? Thanks, Asil ===================== 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 |
|
A side issue.
At 05:37 PM 10/7/2008, Gene Maguin wrote: >I assume every value of name is structured as lastname, firstname. I assume >name is A40. > >String fname lname(a20). >#i=index(name,','). >Compute lname=substr(name,1,#i-1). >Compute fname=substr(name,#i+2,40-#i+1). That is exactly how you do it, though I see a couple of small bugs: For #i=index(name,','). use, of course, COMPUTE #i=index(name,','). And I think the second argument of the second 'substr' is wrong: instead of Compute fname=substr(name,#i+2,40-#i+1). use Compute fname=substr(name,#i+1,40-#i+1). (If the first name may have a leading blank, I'd use LTRIM to eliminate it.) Finally, the third argument of the second 'substr' is not needed. From the Command Syntax Reference, >>SUBSTR(a1, a2, a3) Substring. This function returns the substring >>within a1 beginning with the position specified by a2 and >>optionally for a length of a3. If a3 is not specified, the >>substring is returned up to the end of a1. So Compute fname=substr(name,#i+1). will do just fine. -Cheers, and onward, Richard ===================== 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 |
|
Thank you very much,
This worked fine String fname lname(a20). compute #i=index(name,','). Compute lname=substr(name,1,#i-1). Compute fname=substr(name,#i+2). exec. Asil -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Tuesday, October 07, 2008 6:52 PM To: Gene Maguin; [hidden email] Cc: Asil Ozdogru Subject: Re: Splitting names A side issue. At 05:37 PM 10/7/2008, Gene Maguin wrote: >I assume every value of name is structured as lastname, firstname. I assume >name is A40. > >String fname lname(a20). >#i=index(name,','). >Compute lname=substr(name,1,#i-1). >Compute fname=substr(name,#i+2,40-#i+1). That is exactly how you do it, though I see a couple of small bugs: For #i=index(name,','). use, of course, COMPUTE #i=index(name,','). And I think the second argument of the second 'substr' is wrong: instead of Compute fname=substr(name,#i+2,40-#i+1). use Compute fname=substr(name,#i+1,40-#i+1). (If the first name may have a leading blank, I'd use LTRIM to eliminate it.) Finally, the third argument of the second 'substr' is not needed. From the Command Syntax Reference, >>SUBSTR(a1, a2, a3) Substring. This function returns the substring >>within a1 beginning with the position specified by a2 and >>optionally for a length of a3. If a3 is not specified, the >>substring is returned up to the end of a1. So Compute fname=substr(name,#i+1). will do just fine. -Cheers, and onward, Richard ===================== 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 Richard Ristow
Hello,
How could I move down subtotals to the bottom of the table without changing the rows included in the subtotals within custom tables menu/syntax? Thanks, Asil * Custom Tables. CTABLES /VLABELS VARIABLES=sample site DISPLAY=DEFAULT /TABLE site BY sample [COUNT F40.0] /CATEGORIES VARIABLES=sample ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER /CATEGORIES VARIABLES=site [1, 4, SUBTOTAL='High Sanction', 2, 3, SUBTOTAL='Low Sanction'] EMPTY=INCLUDE TOTAL=YES POSITION=AFTER. Combined study group I II Total Count Count Count Study site A 90 106 196 B 90 105 195 SubAB 180 211 391 C 107 163 270 D 100 140 240 SubCD 207 303 510 Total 387 514 901 I would like to have: Combined study group I II Total Count Count Count Study site A 90 106 196 B 90 105 195 C 107 163 270 D 100 140 240 SubAB 180 211 391 SubCD 207 303 510 Total 387 514 901 -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Tuesday, October 07, 2008 6:52 PM To: Gene Maguin; [hidden email] Cc: Asil Ozdogru Subject: Re: Splitting names A side issue. At 05:37 PM 10/7/2008, Gene Maguin wrote: >I assume every value of name is structured as lastname, firstname. I assume >name is A40. > >String fname lname(a20). >#i=index(name,','). >Compute lname=substr(name,1,#i-1). >Compute fname=substr(name,#i+2,40-#i+1). That is exactly how you do it, though I see a couple of small bugs: For #i=index(name,','). use, of course, COMPUTE #i=index(name,','). And I think the second argument of the second 'substr' is wrong: instead of Compute fname=substr(name,#i+2,40-#i+1). use Compute fname=substr(name,#i+1,40-#i+1). (If the first name may have a leading blank, I'd use LTRIM to eliminate it.) Finally, the third argument of the second 'substr' is not needed. From the Command Syntax Reference, >>SUBSTR(a1, a2, a3) Substring. This function returns the substring >>within a1 beginning with the position specified by a2 and >>optionally for a length of a3. If a3 is not specified, the >>substring is returned up to the end of a1. So Compute fname=substr(name,#i+1). will do just fine. -Cheers, and onward, Richard ===================== 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 |
|
Subtotals in Custom Tables are positioned the way they are in order to avoid generating misleading tables, i.e., relying on the user to have crafted sufficiently explanatory labels.
So you can't move the subtotals. But what you can do is to stack two subtables. Make a copy of the variable. In the first table, don't specify any subtotals. Then add the copy and specify the subtotals you want but choose the hide option. That will give you a table joined below or next to the full table that just contains the subtotals you chose. You can work out the syntax, but you can do all this using the Custom Tables canvas to generate the syntax. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Asil Ozdogru Sent: Thursday, April 02, 2009 9:22 AM To: [hidden email] Subject: [SPSSX-L] Custom tables? Hello, How could I move down subtotals to the bottom of the table without changing the rows included in the subtotals within custom tables menu/syntax? Thanks, Asil * Custom Tables. CTABLES /VLABELS VARIABLES=sample site DISPLAY=DEFAULT /TABLE site BY sample [COUNT F40.0] /CATEGORIES VARIABLES=sample ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER /CATEGORIES VARIABLES=site [1, 4, SUBTOTAL='High Sanction', 2, 3, SUBTOTAL='Low Sanction'] EMPTY=INCLUDE TOTAL=YES POSITION=AFTER. Combined study group I II Total Count Count Count Study site A 90 106 196 B 90 105 195 SubAB 180 211 391 C 107 163 270 D 100 140 240 SubCD 207 303 510 Total 387 514 901 I would like to have: Combined study group I II Total Count Count Count Study site A 90 106 196 B 90 105 195 C 107 163 270 D 100 140 240 SubAB 180 211 391 SubCD 207 303 510 Total 387 514 901 -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Tuesday, October 07, 2008 6:52 PM To: Gene Maguin; [hidden email] Cc: Asil Ozdogru Subject: Re: Splitting names A side issue. At 05:37 PM 10/7/2008, Gene Maguin wrote: >I assume every value of name is structured as lastname, firstname. I assume >name is A40. > >String fname lname(a20). >#i=index(name,','). >Compute lname=substr(name,1,#i-1). >Compute fname=substr(name,#i+2,40-#i+1). That is exactly how you do it, though I see a couple of small bugs: For #i=index(name,','). use, of course, COMPUTE #i=index(name,','). And I think the second argument of the second 'substr' is wrong: instead of Compute fname=substr(name,#i+2,40-#i+1). use Compute fname=substr(name,#i+1,40-#i+1). (If the first name may have a leading blank, I'd use LTRIM to eliminate it.) Finally, the third argument of the second 'substr' is not needed. From the Command Syntax Reference, >>SUBSTR(a1, a2, a3) Substring. This function returns the substring >>within a1 beginning with the position specified by a2 and >>optionally for a length of a3. If a3 is not specified, the >>substring is returned up to the end of a1. So Compute fname=substr(name,#i+1). will do just fine. -Cheers, and onward, Richard ===================== 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 Richard Ristow
How could I create a new ID variable that will assign IDs starting from 1 to n for all cases in my dataset? A unique ID for all cases.
Thanks, Asil ===================== 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 Asil Ozdogru
New_ID = $CASENUM should do what you want. Best. James E. Parry Sr. Sales Engineer, SPSS An IBM Company 233 S. Wacker Dr 11th Floor, Chicago, 60606 Fax: 773.355.2092 Direct: 312.612.2092
How could I create a new ID variable that will assign IDs starting from 1 to n for all cases in my dataset? A unique ID for all cases. Thanks, Asil ===================== 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 Asil Ozdogru
I have this 17-item scale that I want to create a total scale score and 3 subscale scores accounting for missing values. Could anyone help me with a concise syntax? The ones I am trying out gets longer and longer. Here are the specs:
Scale Items: i1 to i17 Factor 1: i1 to i5 Factor 2: i6 to i12 Factor 3: i13 to i17 For total scale score: Sum all items if there are less than 5 missing items and replace missing items with mean values of their corresponding factor For factor scores: Sum factor items if there are less than 2 missing items and replace missing items with mean values of their corresponding factor Asil ===================== 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 |
|
Dear Asil,
The syntax for the sub-scale scores is fairly straightforward. compute fac1 = ( 5 * ( mean.3(i1,i2,i3,i4,i5 ) ) ) . compute fac2 = ( 7 * ( mean.5(i6.i7.i8.j9,i10,i11,i12 ) ) ) . compute fac3 = ( 5 * ( mean.3(i13,i14,i15,i16,i17 ) ) ) . This procedure prorates the scores to make up for missing data when there is not too much missing data. The end result is the same as replacing missing items with mean values of their corresponding factor. I have a question regarding the proposed scoring for the total. The instructions you provide for computing the total would allow one to replace missing items with the mean of the corresponding factor even when there is a lot of missing data on the factor. For example, a subject might have missing data on five items overall, but all five missing items might fall on fac2, or four of the five might fall on fac1 or fac2. I do not think that you want to replace missing data with the mean of the factor in these instances - there is not enough data. I would suggest that you make the procedure for computing the total more consistent with the rules for computing the sub-scale scores. Here is one suggestion for computing the total in this manner: count tm = i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 (missing) . if (tm le 5) tot = (fac1 + fac2 + fac3 ) . This is computationally the same as replacing the missing items with mean values of their corresponding factor provided: a.) there are more than 2 missing items on a given factor; and b.) there are no more than two missing items on any given factor. HTH, Steve Brand www.StatisticsDoc.com On Tue, Apr 6, 2010 at 3:38 PM, Asil Ozdogru wrote: > I have this 17-item scale that I want to create a total scale score > and 3 subscale scores accounting for missing values. Could anyone help > me with a concise syntax? The ones I am trying out gets longer and > longer. Here are the specs: > > Scale Items: i1 to i17 > Factor 1: i1 to i5 > Factor 2: i6 to i12 > Factor 3: i13 to i17 > > For total scale score: > Sum all items > if there are less than 5 missing items > and replace missing items with mean values of their corresponding > factor > > For factor scores: > Sum factor items > if there are less than 2 missing items > and replace missing items with mean values of their corresponding > factor > > > Asil > > > ===================== > 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 Asil Ozdogru
How many values for each item? Before going
for scaling, have you first done...?
1: For all 17 items
freq i1 to i17 /sta mea
.
corr i1 to i17
.
From what you've written
compute scale1a = sum (i1 to
i17) .
sums all items
compute scale1b = sum.17 (i1
to i17) .
sums only if all 17 are
answered
compute scale1c = sum.12 (i1
to i17) .
sums if at least 12 are
answered.
Similarly
For factor 1
comp factor1a =
sum ( i1 to i5) .
comp factor1b = sum.5 ( i1 to i5) . comp factor1c = sum.3 ( i1 to i5) . and check by
freq factor1a to factor1c
/sta mea /his nor .
corr factor1a to
factor1c .
For factor 2
comp factor2a = sum (i6 to i12) .
comp factor2b = sum.7 (i6 to i12) . comp factor2c = sum.5 (i6 to i12) . freq factor2a to factor2c
/sta mea /his nor .
corr factor2a to
factor2c .
For factor 3
comp factor3a = sum (i13 to
i17) .
comp factor3b =
sum.5 (i13 to i17) .
comp factor3c = sum.3 (i13 to i17) . freq factor3a to factor3c
/sta mea /his nor .
corr factor3a to factor3c
.
I've never been one for substituting, but
then I'm not a psychologist. Are you? Don't forget, if you add
too many things together you rapidly lose cases if they have missing values
(perhaps that's why you substitute?) Also the more items you add, the more
the resulting distribution approaches normal.
I'm sure there's a quicker way to substitute a mean
in syntax (one of the regular listers will supply something more elegant) but
get the mean of all 17 items and try (untested):
do
repeat
x = i1 to
i17
/y = <list here all 17 means separated by spaces or
commas> .
if (missing (x)) x = y
.
end repeat
.
Best to check my syntax using SPSS
Help.
----- Original Message -----
|
| Free forum by Nabble | Edit this page |
