|
row case Admit Last svc lagAdmit Admit0506 TimeLapse
1 22 7/29/09 9/8/09 . . . 2 22 11/4/07 11/17/07 7/29/09 . 620 days 3 22 10/5/05 11/3/07 11/4/07 1 1 day Hi everyone, I have a large dataset in which each client can have multiple admits within a certain time period. Iâve used the lag function to calculate the lapse between opening dates and the last service date of the previous opening date in order to merge multiple admits together-my rule is if the time lapse is lt 30 days itâs the same admit. I used this code to get the table above: do if case=lag(case). compute LagOp = lag(opdate). end if. execute. do if lag(case) = case. compute lapse=ABS(xdate.tday(lst_svc)-xdate.tday(lagOp)). end if. I now want to get rid of row 2 above bc the time lapse between admits is too long and itâs not an admit from my original cohort (i.e. admit0506=1. How do I do this? I wanted to use this code but itâs giving me an error about âcomputing lag (drop)=0." compute drop=1. do if admit0506=1 and lapse le 30. compute lag(drop) = 0. compute lst_svc=lag(lst_svc). end if. execute. Select if drop=1. Any help on how to delete this case would be greatly appreciated!! I have way too many records to do this mannually. Tracy ===================== 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 |
|
Hi Tracy
Just focussing on that last block you've hit a restriction in which SPSS will only allow you to compute a value on the current case (not the previous one though - as you've seen lag() can check values on the previous cases). So one suggestion would be to sort the file in reverse order so in effect the lag ends up looking forwards rather than backwards. If we assume that you have a variable called row and that uniquely identifies each case in the current order sequentially (looks like you do but if you don't COMPUTE ROW=$CASENUM. Will get you that) Then ... this is untested ... but should work I'd first make the assignment... do if admit0506=1 and lapse le 30. compute lst_svc=lag(lst_svc). end if. execute. ...then resort the file... SORT CASES BY ROW(d). ... then make the selection the other way round compute drop=0. do if lag(admit0506)=1 and lag(lapse) le 30. compute drop = 1. end if. execute. Select if drop=1. ... to get the file back in the right order ... SORT CASES BY ROW(a). Hope this helps John -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Tracy Hazelton Sent: 02 September 2009 01:03 To: [hidden email] Subject: deleting/marking a record using a lag function row case Admit Last svc lagAdmit Admit0506 TimeLapse 1 22 7/29/09 9/8/09 . . . 2 22 11/4/07 11/17/07 7/29/09 . 620 days 3 22 10/5/05 11/3/07 11/4/07 1 1 day Hi everyone, I have a large dataset in which each client can have multiple admits within a certain time period. I’ve used the lag function to calculate the lapse between opening dates and the last service date of the previous opening date in order to merge multiple admits together-my rule is if the time lapse is lt 30 days it’s the same admit. I used this code to get the table above: do if case=lag(case). compute LagOp = lag(opdate). end if. execute. do if lag(case) = case. compute lapse=ABS(xdate.tday(lst_svc)-xdate.tday(lagOp)). end if. I now want to get rid of row 2 above bc the time lapse between admits is too long and it’s not an admit from my original cohort (i.e. admit0506=1. How do I do this? I wanted to use this code but it’s giving me an error about “computing lag (drop)=0." compute drop=1. do if admit0506=1 and lapse le 30. compute lag(drop) = 0. compute lst_svc=lag(lst_svc). end if. execute. Select if drop=1. Any help on how to delete this case would be greatly appreciated!! I have way too many records to do this mannually. Tracy ===================== 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 |
|
Hi
Has anybody encountered this error while running SPSS 15? --------------------------- Microsoft Visual C++ Runtime Library --------------------------- Runtime Error! Program: c:\ARCHIV~1\spss\spsswin.exe R6034 An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information. Anyway, when I click on OK, the program goes on running, but takes a loooot of time to run a simple ONEWAY with 6 dependent variables, 7 groups (sample sizes around 50 each group) and Dunnett post-hoc test. I have installed again Microsoft C++ 2008, but the problem persists (although I haven't restarted my computer afterwards, I'll try that...). Marta ===================== 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 Tracy Hazelton
Why are you keeping cases where DROP = 1? Normally, 1-0 variables are coded so that 1=Yes and 0 = No. If the variable name is DROP, 1 means "drop the case" and 0 means "do not drop the case". So don't you want to "select if (drop EQ 0)", or equivalently, "select if NOT drop"? As John noted, you can only compute a result on the current row. But you have other issues. You said: "I now want to get rid of row 2 above bc the time lapse between admits is too long and it's not an admit from my original cohort (i.e. admit0506=1. How do I do this?" If I follow that, you want to KEEP cases (rows) where LAPSE is less than or equal to 30, and admit0506 = 0. Is that right? If it is, why do you need to use LAG to go across cases? Doesn't this do what you want? select if (LAPSE LE 30), and (admit0506 EQ 0). exe. Or have I misunderstood?
--
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 John McConnell-2
If you have version 17 or later, note that there is a new command, SHIFT VALUES, that allows you to copy either lag or lead values. It is Transform>Shift Values on the menus.
Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of John McConnell Sent: Wednesday, September 02, 2009 7:22 AM To: [hidden email] Subject: Re: [SPSSX-L] deleting/marking a record using a lag function Hi Tracy Just focussing on that last block you've hit a restriction in which SPSS will only allow you to compute a value on the current case (not the previous one though - as you've seen lag() can check values on the previous cases). So one suggestion would be to sort the file in reverse order so in effect the lag ends up looking forwards rather than backwards. If we assume that you have a variable called row and that uniquely identifies each case in the current order sequentially (looks like you do but if you don't COMPUTE ROW=$CASENUM. Will get you that) Then ... this is untested ... but should work I'd first make the assignment... do if admit0506=1 and lapse le 30. compute lst_svc=lag(lst_svc). end if. execute. ...then resort the file... SORT CASES BY ROW(d). ... then make the selection the other way round compute drop=0. do if lag(admit0506)=1 and lag(lapse) le 30. compute drop = 1. end if. execute. Select if drop=1. ... to get the file back in the right order ... SORT CASES BY ROW(a). Hope this helps John -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Tracy Hazelton Sent: 02 September 2009 01:03 To: [hidden email] Subject: deleting/marking a record using a lag function row case Admit Last svc lagAdmit Admit0506 TimeLapse 1 22 7/29/09 9/8/09 . . . 2 22 11/4/07 11/17/07 7/29/09 . 620 days 3 22 10/5/05 11/3/07 11/4/07 1 1 day Hi everyone, I have a large dataset in which each client can have multiple admits within a certain time period. I’ve used the lag function to calculate the lapse between opening dates and the last service date of the previous opening date in order to merge multiple admits together-my rule is if the time lapse is lt 30 days it’s the same admit. I used this code to get the table above: do if case=lag(case). compute LagOp = lag(opdate). end if. execute. do if lag(case) = case. compute lapse=ABS(xdate.tday(lst_svc)-xdate.tday(lagOp)). end if. I now want to get rid of row 2 above bc the time lapse between admits is too long and it’s not an admit from my original cohort (i.e. admit0506=1. How do I do this? I wanted to use this code but it’s giving me an error about “computing lag (drop)=0." compute drop=1. do if admit0506=1 and lapse le 30. compute lag(drop) = 0. compute lst_svc=lag(lst_svc). end if. execute. Select if drop=1. Any help on how to delete this case would be greatly appreciated!! I have way too many records to do this mannually. Tracy ===================== 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 |
| Free forum by Nabble | Edit this page |
