I have a dataset that I did a lag function on to calculate days between readmissions to a hospital. I am now trying to do a select cases to eliminate the cases that are greater than 30 days to readmit. I am getting the following message.
USE ALL. COMPUTE filter_$=(rehosp > 30). >Error # 4309 in column 1024. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may only >be assigned to numeric variables. Consider using the STRING or NUMBER >function. >Execution of this command stops. VARIABLE LABELS filter_$ 'rehosp > 30 (FILTER)'. VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. FORMATS filter_$ (f1.0). >Error # 4836 in column 9. Text: filter_$ >Only the formats A and AHEX can be applied to string variables. >Execution of this command stops. FILTER BY filter_$. >Error # 4877 in column 11. Text: filter_$ >The filter variable must be a numeric variable. >Execution of this command stops. EXECUTE. My data does have in some of the rows a dot and then the next row would have a number. Here is how my data is arranged: Admission dt Discharge dt 02-Apr-2013 08-Apr-2013 . 07-Jun-2013 11-Jun-2013 60 05-Apr-2013 07-Apr-2013 . 06-Jun-2013 11-Jun-2013 60 Any suggestions on how to do a select cases to remove the cases that are greater than 30 days. Thanks Ann Mazuroski |
Administrator
|
"Character strings may only be assigned to string variables."
That part of the error message suggests (to me) that your rehosp variable might be a string. How did you compute it, exactly?
--
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/). |
In reply to this post by Ann
How are you computing the elapsed time?
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ann Sent: Thursday, July 17, 2014 12:06 PM To: [hidden email] Subject: Select cases I have a dataset that I did a lag function on to calculate days between readmissions to a hospital. I am now trying to do a select cases to eliminate the cases that are greater than 30 days to readmit. I am getting the following message. USE ALL. COMPUTE filter_$=(rehosp > 30). >Error # 4309 in column 1024. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may only >be assigned to numeric variables. Consider using the STRING or NUMBER >function. >Execution of this command stops. VARIABLE LABELS filter_$ 'rehosp > 30 (FILTER)'. VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. FORMATS filter_$ (f1.0). >Error # 4836 in column 9. Text: filter_$ >Only the formats A and AHEX can be applied to string variables. >Execution of this command stops. FILTER BY filter_$. >Error # 4877 in column 11. Text: filter_$ >The filter variable must be a numeric variable. >Execution of this command stops. EXECUTE. My data does have in some of the rows a dot and then the next row would have a number. Here is how my data is arranged: Admission dt Discharge dt 02-Apr-2013 08-Apr-2013 . 07-Jun-2013 11-Jun-2013 60 05-Apr-2013 07-Apr-2013 . 06-Jun-2013 11-Jun-2013 60 Any suggestions on how to do a select cases to remove the cases that are greater than 30 days. Thanks Ann Mazuroski -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-cases-tp5726754.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 Ann
At 12:05 PM 7/17/2014, Ann wrote:
>I have a dataset that I did a lag function on to calculate days >between readmissions to a hospital. I am now trying to do a select >cases to eliminate the cases that are greater than 30 days to >readmit. I am getting the following message(s). The three messages (I've repeated your listing, below) are quite clear about what they mean: variable "filter_$" is a string variable. It must have pre-existed as a string variable before the COMPUTE that gave the first error message, as if it didn't, the COMPUTE would create it as a numeric variable. Check your data and earlier syntax, to see if you can see how it got created as a strong. >USE ALL. >COMPUTE filter_$=(rehosp > 30). > >>Error # 4309 in column 1024. Text: (End of Command) >>Invalid combination of data types in an assignment. Character >>strings may only be assigned to string variables. Numeric and >>logical quantities may only be assigned to numeric >>variables. Consider using the STRING or NUMBER function. >>Execution of this command stops. > >VARIABLE LABELS filter_$ 'rehosp > 30 (FILTER)'. >VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. >FORMATS filter_$ (f1.0). > >>Error # 4836 in column 9. Text: filter_$ >>Only the formats A and AHEX can be applied to string variables. >>Execution of this command stops. >FILTER BY filter_$. >>Error # 4877 in column 11. Text: filter_$ >>The filter variable must be a numeric variable. >>Execution of this command stops. ===================== 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 |
Postscript:
At 03:59 PM 7/17/2014, I wrote: >Check your data and earlier syntax, to see if you can see how >[variable "filter_$"] got created as a string. You'll want to check the contents of the current "filter_$" before deleting it; possibly, somebody used it for information that's important. If you don't want to delete or rename the existing "filter_$", you can create and use a variable with any name you please as the filter variable -- though that flexibility is possible only with syntax. And, decide whether you want to filter the cases (which hides some of them temporarily) or select cases (permanently removing the ones that are deleted -- so make sure you've saved the old file). Selecting (assuming your "rehosp" is computed correctly): SELECT IF rehosp > 30. Filtering, by filter variable "Anns_Filter": USE ALL. COMPUTE Anns_Filter=(rehosp > 30). VARIABLE LABELS Anns_Filter 'rehosp > 30 (FILTER)'. VALUE LABELS Anns_Filter 0 'Not Selected' 1 'Selected'. FORMATS Anns_Filter (f1.0). FILTER BY Anns_Filter. ===================== 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 |
@Ann: filter variables are perfectly normal variables. You can create/keep several of them at once in your dataset. However, only one (or zero) of them can be active at any give timepoint.
Creating filter variables by syntax really is a piece of cake. The main thing to watch out for is that cases having a USER MISSING VALUE on the filter variable don't get the usual strikethrough their $CASENUM even though they are inactivated. This seems to be a really ancient bug in SPSS (would be nice if someone could (dis)confirm that). For more, see http://www.spss-tutorials.com/filter/. |
Administrator
|
Ruben, under what circumstances would one want or need user-defined missing values for a filter variable? A filter variable typically has a value of 1 for the cases one wishes to use, and 0 for the remaining cases. Please provide an example. Thanks! ;-)
Bruce
--
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/). |
v1: "Did you buy this product?"
0 = "No" 1 = "Yes" 2 = "Don't remember" (user missing) Now I want to use only cases who certainly bought the product. FILTER BY v1. does the job correctly but seems to fail here on cases having v1 = 2. Note that cases with v1 = 2 will be active if 2 is not specified as a user missing value. |
Easiest way to confirm is to apply the filter and run a frequency of v1.
M -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben Geert van den Berg Sent: Friday, July 18, 2014 10:35 AM To: [hidden email] Subject: Re: [SPSSX-L] Select cases v1: "Did you buy this product?" 0 = "No" 1 = "Yes" 2 = "Don't remember" (user missing) Now I want to use only cases who certainly bought the product. FILTER BY v1. does the job correctly but /seems/ to fail here on cases having v1 = 2. Note that cases with v1 = 2 /will/ be active if 2 is /not/ specified as a user missing value. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-cases-tp5726754p5726763.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 |
Administrator
|
In reply to this post by Ruben Geert van den Berg
Ruben's reply sent me to the FM entry for FILTER, where I find this in the OVERVIEW section:
"When FILTER is in effect, cases with a zero or missing value for the specified variable are not used in program procedures." So contrary to what I suggested earlier, a filter variable can indeed have valid values other than 0 and 1. (But I think that filter variables computed via the DATA > SELECT CASES dialog will always have values of 1, 0 or system-missing.) I can also confirm Ruben's observation that cases for which the filter variable has a user-defined missing value are excluded, but do not have the case number crossed out in the data editor. The syntax I used to test is shown below. * Confirmation of Ruben's observation about user-defined * missing values for filter variables. DATA LIST free (,) / @Filter. BEGIN DATA. 0,1,2,3,4,5,,9 END DATA. COMPUTE Case = $casenum. FORMATS @Filter Case(F2.0). MISSING VALUES @Filter(9). DESCRIPTIVES Case. LIST. * All cases are used. FILTER by @Filter. DESCRIPTIVES Case. LIST. * For Case 8, @Filter = 9, which is a user-defined missing value. * Case 8 is excluded when the filter is on, but Case 8 is not * crossed out in the data editor. * I am using SPSS 21.0.0.2 for Windows, * Windows 7 Professional, SP1, 64-bit.
--
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/). |
This symptom goes back to at least version 15(!) and perhaps way further.
I discussed it on LinkedIn a while ago and was kinda disappointed that none of the IBM SPSS group members commented on it. Regardless whether you find user missing values on filter variables useful or not, SPSS' behavior should correspond to its documentation. With regard to filter variables, I was trying to demystify them by stating that basically any regular variable can be used as a filter variable if it has the proper values. I think the somewhat bloated syntax that SPSS generates here ("USE ALL." => did any syntax user ever type this?!) may be intimidating to novice syntax learners. Filter variables can be created and used by perfectly clean, basic syntax as long as you know which values cause cases to be active versus inactive. So in first instance, a basic example led me to believe that USER MISSING values would cause cases to be active. Until I ran AGGREGATE, that is... |
It's may be worth noting that if LAG is used with commands that select cases (SELECT IF, FILTER BY, etc), it is implemented after case selection, even if specified before a selection command. That can create some weird results, as I have experienced in other work. If Ann neglected to include an EXECUTE statement immediately after creating her time gap variable, that could throw an error later down the line.
Regards, Bob Walker Surveys & Forecasts, LLC www.safllc.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben Geert van den Berg Sent: Sunday, July 20, 2014 5:03 AM To: [hidden email] Subject: Re: Select cases This symptom goes back to at least version 15(!) and perhaps way further. I discussed it on LinkedIn a while ago and was kinda disappointed that none of the IBM SPSS group members commented on it. Regardless whether you find user missing values on filter variables useful or not, SPSS' behavior should correspond to its documentation. With regard to filter variables, I was trying to demystify them by stating that basically any regular variable can be used as a filter variable if it has the proper values. I think the somewhat bloated syntax that SPSS generates here ("USE ALL." => did any syntax user ever type this?!) may be intimidating to novice syntax learners. Filter variables can be created and used by perfectly clean, basic syntax as long as you know which values cause cases to be active versus inactive. So in first instance, a basic example led me to believe that USER MISSING values would cause cases to be active. Until I ran AGGREGATE, that is... -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-cases-tp5726754p5726766.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 |
Good catch. A recommendation here is
"As a rule of thumb, always run EXECUTE immediately after commands using LAG. This is one of the very few cases where you really need to run EXECUTE or a procedure. The reason for this is rather technical but for those who wonder: LAG is always carried out after all other transformations. This means that the order in which commands are executed deviates from the order in which they're specified. If a variable affected by LAG is used in a subsequent command, the latter is likely to use the ‘wrong’ values because LAG hasn't taken place yet." (from http://www.spss-tutorials.com/lag/) |
Remember that the SHIFT VALUES command
is available to create lagged or lead values and has more intuitive behavior.
Besides not having out-of-order execution, it does not cross split
groups, so it is convenient when you need to process those groups independently.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Ruben Geert van den Berg <[hidden email]> To: [hidden email], Date: 07/24/2014 12:30 AM Subject: Re: [SPSSX-L] Select cases Sent by: "SPSSX(r) Discussion" <[hidden email]> Good catch. A recommendation here is "As a rule of thumb, always run EXECUTE immediately after commands using LAG. This is one of the very few cases where you really need to run EXECUTE or a procedure. The reason for this is rather technical but for those who wonder: LAG is always carried out after all other transformations. This means that the order in which commands are executed deviates from the order in which they're specified. If a variable affected by LAG is used in a subsequent command, the latter is likely to use the ‘wrong’ values because LAG hasn't taken place yet." (from http://www.spss-tutorials.com/lag/) -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Select-cases-tp5726754p5726808.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 |
Free forum by Nabble | Edit this page |