Date: Wed, 22 Nov 2006 14:02:24 -0500
Reply-To: Brian Kelley <bkelley@LAKESTONEG.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Brian Kelley <bkelley@LAKESTONEG.COM>
Subject: Re: Basic loop-vector command help?
Richard, thanks very much; I will pursue the recode angle. I have also
tried to use a macro, which according to the manual should work, but it
does not. So, I'm still struggling to make this code work.
Because you asked ... the reason that I am having to do this is that some
of the FIPS codes are correct, but some are not due to the history of this
data. In some cases, the state FIPS codes were set to "00" and I'm trying
to fix that, so that I can use the data. I can't just do a bulk replace,
unfortunately.
I'll try another way to describe the situation by showing
syntax that DOES work and syntax that DOES NOT work, and maybe someone can
help me, and I'm trying to use a macro instead of vectors which may work
more effectively.
1. GOOD Code. This basic code works by first checking the values in two
fields of my main database (Master_spare) and then depending on the
results of that process, it computes a new value for a third field.
GET FILE='E:\IRS Migration Data\County Migration
Files\Co_9304_Master_spare.sav'.
DATASET NAME Master_IRS WINDOW=FRONT.
If (TO_ST = "00" And TO_ST_ABBR = "AL") To_St_2 = "01".
If (TO_ST = "00" And TO_ST_ABBR = "AK") To_St_2 = "02".
Execute.
2. BAD Code. Because I'm hoping to avoid having to write a single line for
each of the 50 states, and I want to learn more about how to tap the power
of SPSS syntax, I've tried to use vectors, loops and now I'm trying a
macro. Unfortnately, the macro below does not work, although the SPSS file
does have "transformations pending" on the bottom of the screen; when I
choose "run transformations" nothing happens, and my data options are set
on "run transformations immediately". So I don't know what transformations
are pending, but I can't get them to show up, in any event. I've reworked
this macro many times, and it should work given what I can read, but it
does not.
GET FILE='E:\IRS Migration Data\County Migration
Files\Co_9304_Master_spare.sav'.
DATASET NAME Master_IRS WINDOW=FRONT.
DEFINE !No_Zeros (StateFips = !Tokens(1) /StateAbbr = !Tokens(1))
Do if (TO_ST = "00" and TO_ST_ABBR = "AL").
Compute TO_ST_2 = "01".
End If.
!ENDDEFINE.
!No_Zeros "01" "AL".
EXECUTE.
(Result: no change in the main spss file, notification that
Transformations are pending).
Any help would be much appreciated!
best,
Brian