Date: Tue, 18 Jul 2006 14:14:38 -0400
Reply-To: Richard Ristow <email@example.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <firstname.lastname@example.org>
Subject: Re: comparing string to numeric
In-Reply-To: <BE3FA3B86F9D4643B1162B55FBB4FEA4190CE5@exchange.nso.gov.er >
Content-Type: text/plain; charset=us-ascii; format=flowed;
To expand a little on what Hector Maletta wrote, which is correct:
At 11:28 AM 7/18/2006, Samuel Solomon wrote:
>I would like you to help me on how I could compare a string to numeric
>and vice versa.
The broad question is, what does it mean for your string and your
numeric quantities to be the same?
Hector wrote for what's probably the case: your string variable
contains the character representation of a numeric quantity, and 'the
same' means that they represent the same numeric quantity. Unless you
have more specifications, it's the only possible case, because a
numeric quantity does not have a canonical string representation. That
is, a numeric quantity can be converted to a string with the STRING
function; but if the quantity is 3, then '3', '003', and '3.00' are all
possible string conversions, none more representative of the quantity 3
than are any of the others.
So, if you have anything else in mind, you should probably write again.
One caveat: if your string does NOT represent a valid numeric quantity,
then the value of Hectors "newvar" will be system-missing. If you
compare it to your numeric quantity, the comparison will return
'missing', not 'false', and the difference matters in some cases.
So, don't test
"stringvar EQ newvar";