|
Hello- I have a 17.0.2 data set that has only 1 field containing a
string variable, called Macro1 (A40). See table ‘Macro1’ below. I’ve created this field through syntax based on a
sort order of sales by brand in an aggregated data file.
What I would like to do is to automatically create an .sps (syntax) file containing just these
statements. (Call it FILE='C:\BlahBlah\Macro1_Insert.sps'.) I would like to then call that syntax from my main syntax
file and use the macros to rename some field names in a separate data file. Such as: INSERT FILE='C:\BlahBlah\Macro1_Insert.sps'. RENAME VARIABLES (S1 = !s1) (S2 = !s2) (S3 =
!s3) (S4 = !s4) (S5 = !s5) (S99= !s99). This is the format of the data set that I am renaming
variables in.
So after running the rename command, the table should look
like:
The reason that I’ve ended up in this crazy
situation is that: A). The client wants the format as shown above (in Excel,
in fact) B). The final table must always show the top 20 brands (I’ve
only shown 5 in my example), sorted descending Left to Right, with S1 having
the highest sales, and all other that don’t make the top 20 are included
in S99 which receive the label of “Others”. C). The total number of brands varies
each time the data is processed, and brands move in and out of the top 20 and
change their order with each run. D). I want to be able to run the same syntax every time
without having to change it for each run’s specific brands or new order. It’s essentially a Pivot table, but I couldn’t
quite get the right configuration using Custom Tables, so I am trying to get
the data as close to my final formatting as possible through SPSS, before I
drop it into an Excel template. I’m sure there are many different ways to get from
my raw data to my end result, (and I’m definitely open to hearing them),
but since I’m already at this point, I need
to know if I can save a data field or custom table/case summaries table (like ‘Macro1’
above) from the Output viewer as a syntax file that can be called automatically
without any manual interaction. I offer all this extra explanation for
those of you who might ask, “but why?” J Thanks for considering my dilemma, and I appreciate
hearing any thoughts/hints you may have. |
|
I have solved my own problem! Using the WRITE OUTFILE
command and changing it to .sps instead of .txt seems to work! WRITE OUTFILE='K:\Cntyboat\Macro1_Insert.sps' TABLE /macro1 . From: Heidi Green Hello- I have a 17.0.2 data set that has only 1 field containing
a string variable, called Macro1 (A40). See table ‘Macro1’ below. I’ve created this field through syntax based on a
sort order of sales by brand in an aggregated data file.
What I would like to do is to automatically create an .sps (syntax) file containing just these
statements. (Call it FILE='C:\BlahBlah\Macro1_Insert.sps'.) I would like to then call that syntax from my main syntax file
and use the macros to rename some field names in a separate data file. Such as: INSERT FILE='C:\BlahBlah\Macro1_Insert.sps'. RENAME VARIABLES (S1 = !s1) (S2 = !s2) (S3 =
!s3) (S4 = !s4) (S5 = !s5) (S99= !s99). This is the format of the data set that I am renaming
variables in.
So after running the rename command, the table should look
like:
The reason that I’ve ended up in this crazy
situation is that: A). The client wants the format as shown above (in Excel,
in fact) B). The final table must always show the top 20 brands
(I’ve only shown 5 in my example), sorted descending Left to Right, with
S1 having the highest sales, and all other that don’t make the top 20 are
included in S99 which receive the label of “Others”. C). The total number of brands varies
each time the data is processed, and brands move in and out of the top 20 and
change their order with each run. D). I want to be able to run the same syntax every time
without having to change it for each run’s specific brands or new order. It’s essentially a Pivot table, but I couldn’t
quite get the right configuration using Custom Tables, so I am trying to get
the data as close to my final formatting as possible through SPSS, before I
drop it into an Excel template. I’m sure there are many different ways to get from
my raw data to my end result, (and I’m definitely open to hearing them),
but since I’m already at this point, I
need to know if I can save a data field or custom table/case summaries table
(like ‘Macro1’ above) from the Output viewer as a syntax file that
can be called automatically without any manual interaction. I offer
all this extra explanation for those of you who might ask, “but
why?” J Thanks for considering my dilemma, and I appreciate
hearing any thoughts/hints you may have. |
| Free forum by Nabble | Edit this page |
