=========================================================================
Date: Tue, 11 Jul 2006 20:02:14 -0400
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: reverse concat
In-Reply-To: <OFD8DBF14B.0517ED3F-ON852571A8.0071E05C-852571A8.00730071@
AAALIFE.COM>
Content-Type: text/plain; charset=iso-8859-1; format=flowed;
x-avg-checked=avg-ok-711C3D72
OK, I guess most of you know my diatribe. Many
thanks to Jim Marks and for noting this in thread "Easy problem".
At 04:56 PM 7/11/2006, Renji Abraham wrote:
>* If I understand your question correctly your
>current social security number is this form
>'xxx-xx-xxxx' and you want it in 'xxxxxxxxx' (
>i.e. without the dashes).
>
>STRING PART1 (A3) .
>COMPUTE PART1 = SUBSTR (SSN,1,3) .
>EXECUTE .
>STRING PART2 (A2).
>COMPUTE PART2 = SUBSTR (SSN,5,2) .
>EXECUTE .
>STRING PART3 (A4).
>COMPUTE PART3 = SUBSTR (SSN,8,4).
>EXECUTE .
>
>STRING SSN_NEW (A9) .
>COMPUTE SSN_NEW = CONCAT (PART1,PART2,PART3) .
>EXECUTE .
The logic looks fine. But the EXECUTE statements
*are not recommended*. They contribute nothing;
they slow processing, by forcing the whole file
to be read for each one.
Now, diatribe isn't always the best way to make a
point. Would anybody who's an 'EXECUTE' user,
like to say why the statement seems to be a good
idea? Maybe we can help clear up misunderstandings.
(For cases where EXECUTE is needed, see section
"Data Management/ 2. Best Practices and
Efficiency Tips/ Use EXECUTE Sparingly," in:
Levesque, Raynald, and SPSS, Inc., "SPSSŪ
Programming and Data Management, 3rd Edition/A
Guide for SPSSŪ and SASŪ Users". SPSS, Inc.,
Chicago, IL, 2006; downloadable free from the SPSS, Inc., Web site.
>This is a long solution. I think others would have an easier solution.
There are variations, but I can't think of
anything that's much simpler.
-Onward,
|