Date: Wed, 27 May 2009 15:32:40 -0400
Reply-To: Gene Maguin <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Gene Maguin <email@example.com>
Subject: Re: identifying fields with incorrect number of digits
Content-Type: text/plain; charset="us-ascii"
>>I have two fields in my data that I need to identify as having an
incorrect format. One is a 10 byte string variable that has a hyphen in it.
It is incorrect if it doesn't have a hyphen and is less than 10 bytes
(including the hyphen). The other is a 9 byte string variable (ssn). If it
has less than 9 bytes it is incorrect. How can I do this?
One way to do this is to search field 1 for a hyphen and check its length.
Like this but note assumptions. Assumptions: 1) if field 1 is less than 10
characters, the trailing characters are blanks. 2) the '-' character
(located on the key to the right of the '0'/')' key on a US keyboard is used
as a hyphen. If that character is not the hyphen character (and it might not
be), then you have figure out the character being used and its code. The
table in the back of the syntax references is, I think, useless for this but
somebody as spss will know or, very likely, Richard will know.
Compute err=1. /* an error is the default.
If (char.length(field1) eq 10 and index(field1,'-') gt 0) err=0.
The second problem is a simplification of the first.
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
For a list of commands to manage subscriptions, send the command