|
Hello,
I would like to delete some cases from my data set using syntax. Kindly help. Nyougo. ===================== 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 |
|
select if not ( ----state conditions defining cases you want to delete-----).
On 10/17/07, Nyougo Omae. <[hidden email]> wrote: > Hello, > > I would like to delete some cases from my data set using syntax. > Kindly help. > > Nyougo. > > ===================== > 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 Nyougo Omae.
In that case, you could use the $casenum function:
select if $casenum <> 1. exe. Just remember that after case #1 is gone, the first next case that isn't deleted becomes case 1. It's better to use an id that is tied directly to the case: select if ~(id = '123456'). * (~ = "not"). - or if you want to delete by some combination of classifications: select if ~(sex = 'M' & hair_color = 'Brown'). *this deletes males with brown hair. Whatever you do, backup your original dataset before you start playing around with select statements. It's a real good way to lose a lot of data fast! I much prefer to create a flag using the conditions I plan to use to visually verify that I got it right. So, for example: compute flag = ~(sex = 'M' & hair_color = 'Brown'). exe. Then visually confirm that the right people have been flagged for deletion. After you're convinced, change the compute statment to a select statement. But that's just me - I'm cautious. Good Luck! Gary On 10/17/07, [hidden email] <[hidden email]> wrote: > > Hello, > > Just to make sure that i follow. Say i want to delete case 1 > > select if not ( case nb = 1) . I am new to syntax :) > > Thank you. > > > -------------- Original message -------------- > From: Hal 9000 <[hidden email]> > > > select if not ( ----state conditions defining cases you want to > delete-----). > > > > On 10/17/07, Nyougo Omae. wrote: > > > Hello, > > > > > > I would like to delete some cases from my data set using syntax. > > > Kindly help. > > > > > > Nyougo. > > > > > > ===================== > > > 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 |
|
At 06:22 PM 10/17/2007, Hal 9000 wrote:
>select if ~(id = '123456'). > >* (~ = "not"). > >- or if you want to delete by some combination of classifications: > >select if ~(sex = 'M' & hair_color = 'Brown'). > >*this deletes males with brown hair. > >Whatever you do, backup your original dataset before you start playing >around with select statements. It's a real good way to lose a lot of >data fast! While we're at it: never run ANY transformation program on the only copy of the data, whether or not it deletes cases. Have the data in a .SAV file (usually); load it; run the transformations; and save it *under another name*. (I commonly use the convention that the name of the new .SAV file is the same as the name of the .SPS syntax file that created it.) >I much prefer to create a flag using the conditions I plan to use to >visually verify that I got it right. So, for example: > >compute flag = ~(sex = 'M' & hair_color = 'Brown'). >exe. > >Then visually confirm that the right people have been flagged for >deletion. After you're convinced, change the compute statment to a >select statement. But that's just me - I'm cautious. A lot more people have died of too little caution than of too much. But if I did this, I wouldn't even change the "compute" statement; I'd SELECT IF flag EQ 1. By the by, comparing CROSSTABS of (in this case) "sex" and "hair_color" before and after selection, is another good test and confirmation. ===================== 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,
In addition to Richard's advice: One trick to make it impossible to loose your original data set is to put its file attribute to read-only. You can even do that from SPSS (v12 > (?)): HOST COMMAND = ['attrib +r d:\temp\myfile.sav']. Of course you can also do it in Windows, by just ticking the right box under file properties. Cheers!! Albert-Jan --- Richard Ristow <[hidden email]> wrote: > At 06:22 PM 10/17/2007, Hal 9000 wrote: > > > >select if ~(id = '123456'). > > > >* (~ = "not"). > > > >- or if you want to delete by some combination of > classifications: > > > >select if ~(sex = 'M' & hair_color = 'Brown'). > > > >*this deletes males with brown hair. > > > >Whatever you do, backup your original dataset > before you start playing > >around with select statements. It's a real good way > to lose a lot of > >data fast! > > While we're at it: never run ANY transformation > program on the only > copy of the data, whether or not it deletes cases. > Have the data in a > .SAV file (usually); load it; run the > transformations; and save it > *under another name*. (I commonly use the convention > that the name of > the new .SAV file is the same as the name of the > .SPS syntax file that > created it.) > > >I much prefer to create a flag using the conditions > I plan to use to > >visually verify that I got it right. So, for > example: > > > >compute flag = ~(sex = 'M' & hair_color = 'Brown'). > >exe. > > > >Then visually confirm that the right people have > been flagged for > >deletion. After you're convinced, change the > compute statment to a > >select statement. But that's just me - I'm > cautious. > > A lot more people have died of too little caution > than of too much. > > But if I did this, I wouldn't even change the > "compute" statement; I'd > > SELECT IF flag EQ 1. > > By the by, comparing CROSSTABS of (in this case) > "sex" and "hair_color" > before and after selection, is another good test and > confirmation. > > ===================== > 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 > Cheers! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.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 |
|
Actually, there is an entry on the SPSS File menu to mark a sav file as read only.
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-jan Roskam Sent: Thursday, October 18, 2007 5:28 AM To: [hidden email] Subject: Re: [SPSSX-L] Deleting Cases Hi, In addition to Richard's advice: One trick to make it impossible to loose your original data set is to put its file attribute to read-only. You can even do that from SPSS (v12 > (?)): HOST COMMAND = ['attrib +r d:\temp\myfile.sav']. Of course you can also do it in Windows, by just ticking the right box under file properties. Cheers!! Albert-Jan ===================== 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 01:14 PM 10/18/2007, Peck, Jon wrote:
>Actually, there is an entry on the SPSS File menu to mark a sav file >as read only. So there is. It's implemented by issuing the syntax command PERMISSIONS. New one on me: learn something new every day. (I wonder when it came in? It is in 14; it doesn't seem to be in 9; and I don't have any syntax manuals in between.) CAUTION: The menu entry affects the file loaded as the current working file. (If the current working file isn't associated with a .SAV file, the menu entry is grayed out - reasonably enough.) But if you want to save a file as read-only, save it and AFTERWARD use the "Mark File Read-Only" entry (File menu). Here's a log, from trying it. All the commands were clicked up from the menus and executed (not pasted). The two PERMISSIONS commands were generated from the "Mark File Read-Only" menu entry. The SAVE is from the "Save as..." menu entry. GET FILE='C:\Documents and Settings\Richard\My Documents\Temporary\SPSS\Rubri'+ 'c data PRE- READ-ONLY.sav'. DATASET NAME DataSet1 WINDOW=FRONT. PERMISSIONS FILE = 'C:\Documents and Settings\Richard\My Documents\Temporary\SPS S\Rubric data PRE- READ-ONLY.sav' /PERMISSIONS READONLY. SAVE OUTFILE='C:\Documents and Settings\Richard\My Documents\Temporary\SPSS\Rubr ic data SAVE AS READ-ONLY.sav' /COMPRESSED. PERMISSIONS FILE = 'C:\Documents and Settings\Richard\My Documents\Temporary\SPS S\Rubric data SAVE AS READ-ONLY.sav' /PERMISSIONS READONLY. Interesting suggestion: on Save/Save AS dialog boxes, an option for "save as read only", that would be implemented by emitting a PERMISSIONS command following the SAVE. ===================== 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 |
|
For the syntax lovers, there is PERMISSIONS subcommand on SAVE, so you can save and make read only in the same command.
The PERMISSIONS subcommand sets the operating system read/write permissions for the file. READONLY File permissions are set to read-only for all users. The file cannot be saved by using the same file name with subsequent changes unless the read/write permissions are changed in the operating system or the subsequent SAVE command specifies PERMISSIONS=WRITEABLE. WRITEABLE File permissions are set to allow writing for the file owner. If file permissions were set to read-only for other users, the file remains read-only for them. Jon Peck -----Original Message----- From: Richard Ristow [mailto:[hidden email]] Sent: Thursday, October 18, 2007 1:27 PM To: Peck, Jon; [hidden email] Subject: Re: Deleting Cases At 01:14 PM 10/18/2007, Peck, Jon wrote: >Actually, there is an entry on the SPSS File menu to mark a sav file >as read only. So there is. It's implemented by issuing the syntax command PERMISSIONS. New one on me: learn something new every day. (I wonder when it came in? It is in 14; it doesn't seem to be in 9; and I don't have any syntax manuals in between.) CAUTION: The menu entry affects the file loaded as the current working file. (If the current working file isn't associated with a .SAV file, the menu entry is grayed out - reasonably enough.) But if you want to save a file as read-only, save it and AFTERWARD use the "Mark File Read-Only" entry (File menu). Here's a log, from trying it. All the commands were clicked up from the menus and executed (not pasted). The two PERMISSIONS commands were generated from the "Mark File Read-Only" menu entry. The SAVE is from the "Save as..." menu entry. GET FILE='C:\Documents and Settings\Richard\My Documents\Temporary\SPSS\Rubri'+ 'c data PRE- READ-ONLY.sav'. DATASET NAME DataSet1 WINDOW=FRONT. PERMISSIONS FILE = 'C:\Documents and Settings\Richard\My Documents\Temporary\SPS S\Rubric data PRE- READ-ONLY.sav' /PERMISSIONS READONLY. SAVE OUTFILE='C:\Documents and Settings\Richard\My Documents\Temporary\SPSS\Rubr ic data SAVE AS READ-ONLY.sav' /COMPRESSED. PERMISSIONS FILE = 'C:\Documents and Settings\Richard\My Documents\Temporary\SPS S\Rubric data SAVE AS READ-ONLY.sav' /PERMISSIONS READONLY. Interesting suggestion: on Save/Save AS dialog boxes, an option for "save as read only", that would be implemented by emitting a PERMISSIONS command following the SAVE. |
| Free forum by Nabble | Edit this page |
