|
Thanks to Art and Gene for their help, but I'm still struggling to make
this code work. 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. I've reworked this macro many times, and it should work, 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.
Any help would be much appreciated!
best,
Brian
|