Date: Wed, 25 Oct 2006 14:43:37 -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: Is it possible to create custom Template files?
In-Reply-To: <3D8719E6918A974AB3372C5366EE48EA08CBD3@FSE01.duoc.edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed
Hi, Gary!
At 02:18 PM 10/23/2006, Moser, Gary wrote:
>I am very pleased with the subcommands 'apply template' and 'save
>template' on the autorecode command. What if I want to create a
>template that has numbers assigned to values in non-ordinal
>arrangements? Can I create a template that I can apply and update via
>autorecode that does not require my values to sorted to begin with?
Boy, I sure thought so. For one,
>at 01:28 PM 3/11/2006, Michael Healy <healym@earthlink.net> wrote
>("Re: Speeding up Recode"):
>
>>I use AUTORECODE with the APPLY TEMPLATE option. The template file
>>turns out to be a standard SPSS data file. The manual states that
>>creating your own files is experimental, but so far its working
>>fine. This procedure is hundreds if not thousands of times faster
>>than the RECODE approach I was using. [The speedup was for a RECODE
>>with hundreds of clauses.]
And I'm pretty sure I tested it myself at that point (using SPSS 9),
and had it work for me. I was going to post you a nice demonstration
(SPSS 14). Instead, the test run, with problems, is below. You will
see,
- The auto-generated template file appears, as stated, to be a normal
SPSS data file; it can be GET FILEd and LISTed. (By the way, SPSS 14
datasets don't seem to work. Design, or oversight?) And it can be
APPLYed, and work properly.
- BUT, the user-generated template file fails in a very interesting
way:
A. There's no error message
B. AUTORECODE obviously reads the template file. You'll see that it
assigns VALUE LABELS for the specifications in the template file.
(AUTORECODE always assigns the character source values as labels for
the numerical target values.)
C. However, it seems to create and apply a whole new set of RECODE
specifications:
- The new specifications recode the values in alphabetical order
(sigh).
- The new target values are numbered sequentially after the
user-specified ones.
- The correct VALUE LABELS are assigned for the new specifications; the
target variable therefore has labels for both the user-specified,
desired, target values, and the (apparently) generated target values.
SPSS, Inc: Comments?
The following run, SPSS draft output using 14.0.2, illustrates all of
the above.
* ................................................... .
* ............ AUTORECODE, create a template ...... .
GET FILE=TestData.
LIST.
List
|-----------------------------|---------------------------|
|Output Created |25-OCT-2006 14:12:22 |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
\2006-10-23 Moser - Is it possible to create custom Template files
DATA.SAT
CharVar
Alpha
Beta
Gamma
Delta
Epsilon
Eta
Theta
Number of cases read: 7 Number of cases listed: 7
DATASET DECLARE AutoTmpl.
AUTORECODE CharVar
/INTO NmbrAuto
/SAVE TEMPLATE=AutoTmpl.
LIST.
List
|-----------------------------|---------------------------|
|Output Created |25-OCT-2006 14:12:22 |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
\2006-10-23 Moser - Is it possible to create custom Template files
DATA.SAT
CharVar NmbrAuto
Alpha 1
Beta 2
Gamma 6
Delta 3
Epsilon 4
Eta 5
Theta 7
Number of cases read: 7 Number of cases listed: 7
* ............ Load and list the template ...... .
GET FILE=AutoTmpl.
LIST.
List
|-----------------------------|---------------------------|
|Output Created |25-OCT-2006 14:12:23 |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
\2006-10-23 Moser - Is it possible to create custom Template files
GENERATED TEMPLATE.SAT
Source_ Target_
Alpha 1
Beta 2
Delta 3
Epsilon 4
Eta 5
Gamma 6
Theta 7
Number of cases read: 7 Number of cases listed: 7
* ............ Create a user's template ...... .
NEW FILE.
DATA LIST FREE / Source_ (A8) Target_ (F3).
* ... BEGIN DATA
* ... Alpha 101 Beta 102 Gamma 103 Delta 104 Epsilon 105 Theta 107.
* ... END DATA.
BEGIN DATA
Alpha 101 Beta 102 Gamma 103 Delta 104 Epsilon 105 Eta 106 Theta 107.
END DATA.
* ............ List and save template ...... .
* - 'Eta' is not included in values to be recoded .
* - Variable "Source_" is (A8); variable to be .
* recoded is (A12).
SORT CASES BY Source_.
SAVE OUTFILE=UserTmpl.
* ............ Load and list the template ...... .
GET FILE=UserTmpl.
LIST.
List
|-----------------------------|---------------------------|
|Output Created |25-OCT-2006 14:12:26 |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
\2006-10-23 Moser - Is it possible to create custom Template files
TEMPLATE CREATED BY USER.SAT
Source_ Target_
Alpha 101
Beta 102
Delta 104
Epsilon 105
Eta 106
Gamma 103
Theta 107
Number of cases read: 7 Number of cases listed: 7
* ............ Recode, with both templates ...... .
GET FILE=TESTDATA.
AUTORECODE CharVar
/INTO NmbrAuto
/APPLY TEMPLATE=AutoTmpl.
AUTORECODE CharVar
/INTO NmbrUser
/APPLY TEMPLATE=UserTmpl.
FORMATS NmbrUser (F4).
LIST.
List
|-----------------------------|---------------------------|
|Output Created |25-OCT-2006 14:12:27 |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
\2006-10-23 Moser - Is it possible to create custom Template files
DATA.SAT
CharVar NmbrAuto NmbrUser
Alpha 1 108
Beta 2 109
Gamma 6 113
Delta 3 110
Epsilon 4 111
Eta 5 112
Theta 7 114
Number of cases read: 7 Number of cases listed: 7
DISPLAY DICTIONARY.
File Information
|-----------------------------|---------------------------|
|Output Created |25-OCT-2006 14:12:27 |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
\2006-10-23 Moser - Is it possible to create custom Template files
DATA.SAT
Variable Information
|--------|--------|------|------------|-------|---------|-------|-------|
|Variable|Position|Label |Measurement |Column
|Alignment|Print |Write |
| | | |Level |Width | |Format |Format
|
|--------|--------|------|------------|-------|---------|-------|-------|
|CharVar
|1 |<none>|Nominal |14 |Left |A12 |A12 |
|--------|--------|------|------------|-------|---------|-------|-------|
|NmbrAuto|2 |<none>|Nominal |10 |Right |F1 |F1
|
|--------|--------|------|------------|-------|---------|-------|-------|
|NmbrUser|3 |<none>|Nominal |10 |Right |F4 |F4
|
|--------|--------|------|------------|-------|---------|-------|-------|
Variables in the working file
Variable Values
|--------|---|-------|
|Value | |Label |
|--------|---|-------|
|NmbrAuto|1 |Alpha |
| |2 |Beta |
| |3 |Delta |
| |4 |Epsilon|
| |5 |Eta |
| |6 |Gamma |
| |7 |Theta |
|--------|---|-------|
|NmbrUser|101|Alpha |
| |102|Beta |
| |103|Gamma |
| |104|Delta |
| |105|Epsilon|
| |106|Eta |
| |107|Theta |
| |---|-------|
| |108|Alpha |
| |109|Beta |
| |110|Delta |
| |111|Epsilon|
| |112|Eta |
| |113|Gamma |
| |114|Theta |
|--------|---|-------|