Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete cases through syntax?

20,871 views
Skip to first unread message

Filip Van Droogenbroeck

unread,
Jan 3, 2011, 6:00:52 AM1/3/11
to
Happy new year to everybody,

Is it possible to delete cases through the syntax? I know it is
possible to delete variables through the syntax but I can't find the
equivalent cases.

Kind regards,
Filip Van Droogenbroeck
http://www.vub.ac.be/TOR/

Andy W

unread,
Jan 3, 2011, 8:27:11 AM1/3/11
to
On Jan 3, 6:00 am, Filip Van Droogenbroeck

If you have some type of criterion within a variable you can use
select if statements to delete particular cases.

*This syntax would only keep cases with a value of 1 for the variable
named V1.

select if V1 = 1.

*This syntax would only keep cases that did not have a value of 1.

select if V1 <> 1.

JKPeck

unread,
Jan 3, 2011, 10:11:29 AM1/3/11
to

The SELECT IF approach works well if you have criteria that can be
coded reasonably as a Boolean formula. If, instead, you have a list
of ID values, say, for the cases to be deleted, rather than writing
out a long formula that tests the ID against this list, it is much
easier to make a dataset listing those ids; then match it against the
original, creating a new variable, say, BADID. Then select on BADID
not missing.

If the list of bad id's is reasonably short, you can use the ANY
function to avoid having to write a long list of equality conditions,
e.g.,
any(id, 10,21,66, 44).

HTH,
Jon Peck

sven.sa...@gmail.com

unread,
Aug 22, 2013, 3:36:15 AM8/22/13
to
full example:

RECODE ID (ELSE=0) INTO DELETE.
VARIABLE LABELS DELETE 'case to be deleted?'.
EXECUTE.
FORMATS DELETE (F1.0).
VARIABLE WIDTH DELETE (11).
VALUE LABELS DELETE 0 "no, keep it"
1 "yes, delete".

DO IF (ANY(ID,123,457,679,2207)).
RECODE DELETE (ELSE=1).
END IF.
EXECUTE.

FILTER OFF.
USE ALL.
SELECT IF (DELETE = 0).
EXECUTE.


Op maandag 3 januari 2011 16:11:29 UTC+1 schreef Jon Peck:

Bruce Weaver

unread,
Aug 22, 2013, 8:58:31 AM8/22/13
to
On 22/08/2013 3:36 AM, sven.sa...@gmail.com wrote:
> full example:
>
> RECODE ID (ELSE=0) INTO DELETE.
> VARIABLE LABELS DELETE 'case to be deleted?'.
> EXECUTE.
> FORMATS DELETE (F1.0).
> VARIABLE WIDTH DELETE (11).
> VALUE LABELS DELETE 0 "no, keep it"
> 1 "yes, delete".
>
> DO IF (ANY(ID,123,457,679,2207)).
> RECODE DELETE (ELSE=1).
> END IF.
> EXECUTE.
>
> FILTER OFF.
> USE ALL.
> SELECT IF (DELETE = 0).
> EXECUTE.


If I follow, that could be shortened to:

SELECT IF NOT ANY(ID,123,457,679,2207).
EXECUTE.


--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0 new messages