Saving the results of Match files

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Saving the results of Match files

UMD_user
Hello,

I am wondering if there is a workaround in SPSS (or if I am just not understanding how the DATASET commands work) to be able to save the results of a Match files with DATASETS using syntax? For example, I get two files and name them with the DATASET command (code below). Then, I match the two files and this produces an entirely new file that shows as an unnamed dataset. I attempt to save this new, unnamed dataset...however, when I do, SPSS looks at what it considers the "active" dataset (COMPFALL10) and instead saves this file and closes my newly created unnamed dataset. I have tried every possible combination of using DATASET NAME, DATASET CLOSE, DATASET ACTIVATE, etc. that I can think of to get around this and save my newly created unnamed dataset using syntax and close the original two that I no longer need without altering them. Any suggestions or is this just impossible via syntax? Thank you.


GET FILE = 'X:\SPSS Documents\Enrollment\ADMISSIONS FALL 10.SAV'.
DATASET NAME COMPFALL10.
SORT CASES BY EMPLID.

GET FILE = 'X:\SPSS Documents\Enrollment\UNDUP ENROLL FALL 10.SAV'.
DATASET NAME UNDUPFALL10.
SORT CASES BY EMPLID.

MATCH FILES /FILE = COMPFALL10
   /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
   /TABLE = UNDUPFALL10
   /BY EMPLID
   /KEEP = EMPLID SEX AGE_OCT ACAD_PLAN_FALL ACADPLAN CUMGPA.
EXECUTE.

SAVE OUTFILE='X:\Excel Documents\Fall 10 Nonreturners\Fall 10 Day Nonreturnee Comparison.sav'
  /COMPRESSED.
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Bruce Weaver
Administrator
What happens if you name the merged dataset before trying to save it?


UMD_user wrote
Hello,

I am wondering if there is a workaround in SPSS (or if I am just not understanding how the DATASET commands work) to be able to save the results of a Match files with DATASETS using syntax? For example, I get two files and name them with the DATASET command (code below). Then, I match the two files and this produces an entirely new file that shows as an unnamed dataset. I attempt to save this new, unnamed dataset...however, when I do, SPSS looks at what it considers the "active" dataset (COMPFALL10) and instead saves this file and closes my newly created unnamed dataset. I have tried every possible combination of using DATASET NAME, DATASET CLOSE, DATASET ACTIVATE, etc. that I can think of to get around this and save my newly created unnamed dataset using syntax and close the original two that I no longer need without altering them. Any suggestions or is this just impossible via syntax? Thank you.


GET FILE = 'X:\SPSS Documents\Enrollment\ADMISSIONS FALL 10.SAV'.
DATASET NAME COMPFALL10.
SORT CASES BY EMPLID.

GET FILE = 'X:\SPSS Documents\Enrollment\UNDUP ENROLL FALL 10.SAV'.
DATASET NAME UNDUPFALL10.
SORT CASES BY EMPLID.

MATCH FILES /FILE = COMPFALL10
   /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
   /TABLE = UNDUPFALL10
   /BY EMPLID
   /KEEP = EMPLID SEX AGE_OCT ACAD_PLAN_FALL ACADPLAN CUMGPA.
EXECUTE.

SAVE OUTFILE='X:\Excel Documents\Fall 10 Nonreturners\Fall 10 Day Nonreturnee Comparison.sav'
  /COMPRESSED.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

UMD_user
It renames what it considers the active dataset instead and I lose the new dataset that resulted from the merge.
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Rick Oliver-3
get file=x.
dataset name x.
get file=y.
dataset name y.
match files file=x /table=y /by somevar.
dataset name z.
dataset activate z.
dataset close all.

This should close the original two files and leave the matched dataset (now unnamed). The last line could also be:

dataset close x y.

This preserves the dataset name for the matched dataset.


From:        UMD_user <[hidden email]>
To:        [hidden email]
Date:        05/04/2011 04:03 PM
Subject:        Re: Saving the results of Match files
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




It renames what it considers the active dataset instead and I lose the new
dataset that resulted from the merge.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Saving-the-results-of-Match-files-tp4370649p4371090.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Richard Ristow
In reply to this post by UMD_user
At 01:24 PM 5/4/2011, UMD_user wrote:

>I am wondering if there is a workaround in SPSS to be able to save
>the results of a Match files with DATASETS using syntax? I get two files
>and name them with the DATASET command (code below). Then, I match the two
>files and this produces an entirely new file that shows as an unnamed
>dataset. I attempt to save this new, unnamed dataset...however, when I do,
>SPSS looks at what it considers the "active" dataset (COMPFALL10) and
>instead saves this file and closes my newly created unnamed dataset.

Are you, perhaps, using the menus to generate your syntax?

In SPSS, unfortunately, the term 'active' dataset has two meanings.
There is always one dataset 'active' in both senses; but they may not
be the same dataset, and when they aren't, strange things can happen.

One 'active' dataset is the one that all syntax commands run on. This
is the meaning of 'active' in the *Command Syntax Reference*, and
DATASET ACTIVATE makes the named dataset 'active' in this sense. The
file your MATCH FILE creates *is* the active one in this sense --
that's easy to prove, since an unnamed dataset cannot be inactive.

The other 'active' dataset is the one that *menu* commands refer to.
You can make a dataset 'active' in this sense by clicking on its
window, or by specifying WINDOW=FRONT on a DATASET command that refers to it.

You have,

>MATCH FILES /FILE = COMPFALL10
>    /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
>    /TABLE = UNDUPFALL10
>    /BY EMPLID
>    /KEEP = EMPLID SEX AGE_OCT ACAD_PLAN_FALL ACADPLAN CUMGPA.

You didn't generate this using the menus, because MATCH FILES from
the menus always begins with '/FILE=*'. (There's no need for the
EXECUTE, by the way.)

When you run it, the newly created file is 'active' for SPSS
commands; but the dataset that is 'active' for the menus is
unchanged; in your case, that's apparently COMPFALL10.

Then you have,

>SAVE OUTFILE='X:\Excel Documents\Fall 10 Nonreturners\Fall 10 Day
>Nonreturnee Comparison.sav'
>   /COMPRESSED.

If you generate this from the menus, SPSS 'thinks' you want the
command to apply to the dataset that is 'active' for the menus; and
before running the command, it issues a 'DATASET ACTIVATE' for that
dataset -- presumably . Doing that will, indeed, de-activate the
dataset you just created; since it's unnamed, that will also lose it.
(For added confusion, the DATASET ACTIVATE command is not displayed.)

You *should* be able to get what you want by either using your SAVE
command, but either writing it or pasting it; in any case, not using the menus.

Or, after the MATCH FILES you can add

DATASET NAME MERGED WINDOW=FRONT.

which will make that dataset 'active' in *both* senses, and the menus
should give you what you want. "WINDOW=FRONT" is important.

Sigh. See lengthy discussion under subject heads 'version 15.0.1
bug?' and '"Active" dataset', begun respectively on 31 Mar 2007 and
on 30 Apr 2007.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

UMD_user
I tried adding the DATASET NAME MERGED WINDOW=FRONT command line after the merge but unfortunately that did not work either (per below). SPSS closed my new file and just renamed the COMPFALL10 file as MERGED. This definitely does seem to be a bug. I am entirely using syntax...nothing from the menus to generate the code.

GET FILE = 'U:\Sample syntax\Fall 10 Day Nonreturnee Comparison.sav'.
DATASET NAME COMPFALL10.
SORT CASES BY EMPLID.

GET FILE = 'X:\SPSS Documents\Enrollment\UNDUP ENR FALL 10.SAV'.
DATASET NAME UNDUPFALL10.
SORT CASES BY EMPLID.

MATCH FILES /FILE = COMPFALL10
   /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
   /TABLE = UNDUPFALL10
   /BY EMPLID
   /KEEP = EMPLID SEX AGE_OCT ETHNIC_FED RESCD ACAD_PLAN_FALL ACADPLAN CUMGPA.
EXECUTE.

DATASET NAME MERGED WINDOW=FRONT.

SAVE OUTFILE='U:\Sample syntax\Fall 10 Day Nonreturnee Comparison_1.sav'
  /COMPRESSED.
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Bruce Weaver
Administrator
Rick Oliver suggested:

get file=x.
dataset name x.
get file=y.
dataset name y.
match files file=x /table=y /by somevar.
dataset name z.
dataset activate z.
dataset close all.

This suggests that in your case, you need to try one of the following:

DATASET NAME MERGED WINDOW=FRONT.
DATASET ACTIVATE MERGED.

SAVE OUTFILE='U:\Sample syntax\Fall 10 Day Nonreturnee Comparison_1.sav'
  /COMPRESSED.

OR...

DATASET NAME MERGED WINDOW=FRONT.
DATASET ACTIVATE MERGED.
DATASET CLOSE ALL.

SAVE OUTFILE='U:\Sample syntax\Fall 10 Day Nonreturnee Comparison_1.sav'
  /COMPRESSED.



UMD_user wrote
I tried adding the DATASET NAME MERGED WINDOW=FRONT command line after the merge but unfortunately that did not work either (per below). SPSS closed my new file and just renamed the COMPFALL10 file as MERGED. This definitely does seem to be a bug. I am entirely using syntax...nothing from the menus to generate the code.

GET FILE = 'U:\Sample syntax\Fall 10 Day Nonreturnee Comparison.sav'.
DATASET NAME COMPFALL10.
SORT CASES BY EMPLID.

GET FILE = 'X:\SPSS Documents\Enrollment\UNDUP ENR FALL 10.SAV'.
DATASET NAME UNDUPFALL10.
SORT CASES BY EMPLID.

MATCH FILES /FILE = COMPFALL10
   /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
   /TABLE = UNDUPFALL10
   /BY EMPLID
   /KEEP = EMPLID SEX AGE_OCT ETHNIC_FED RESCD ACAD_PLAN_FALL ACADPLAN CUMGPA.
EXECUTE.

DATASET NAME MERGED WINDOW=FRONT.

SAVE OUTFILE='U:\Sample syntax\Fall 10 Day Nonreturnee Comparison_1.sav'
  /COMPRESSED.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Richard Ristow
In reply to this post by UMD_user
At 09:08 AM 5/5/2011, UMD_user wrote:

>I tried adding the DATASET NAME MERGED WINDOW=FRONT command after
>the merge but that did not work either (per below). SPSS closed my
>new file and just renamed the COMPFALL10 file as MERGED.  I am
>entirely using syntax...nothing from the menus to generate the code.
>This definitely does seem to be a bug.

I'd bet against it, myself, because so many people, so often, have
done things like this and seen no such problem. But if you can get it
to happen reproducibly, with data files that you can send to SPSS, by
all means report it and see what they say. Tell them what kind of
computer, what operating system and version, and what version of
SPSS, you are using. If you would, tell us those things as well.

Below I give the listing of a program set up like yours is, that ran
exactly as it's supposed to.

BUT, when I tested the first version of that program, I *thought* I
saw what you describe: one of the three datasets was lost; of the two
that remained, one had the name 'Merged', but had the contents of one
of the inputs; there was no dataset with the name of that input
dataset, and none containing the merged results. I thought if it had
happened once it would happen again with the program fully set up,
but all later tests have worked just as expected. So I don't know
what to say. I can't prove I saw the problem, and I'm not sure I
believe it myself; but I'm now wondering if something odd does happen
sometimes.

GET FILE=
       'C:\Documents and Settings\Richard\My Documents'               +
         '\Technical\spssx-l\Z-2011\'                                 +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - NAMES.SAV'.

DATASET NAME Names.
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |06-MAY-2011 19:58:32       |
|-----------------------------|---------------------------|
[Names] C:\Documents and Settings\Richard\My Documents
           \Technical\spssx-l\Z-2011\
           2011-05-05 UMD_user - Re-Saving the results of Match files
- NAMES.SAV

RomanLtr Name     Family

A        Aaron    Watson
A        Alice    Urban
A        Andrew   Vance
B        Betty    Williams
B        Bill     Ulam

Number of cases read:  5    Number of cases listed:  5


SORT CASES BY RomanLtr.
GET FILE=
       'C:\Documents and Settings\Richard\My Documents'               +
         '\Technical\spssx-l\Z-2011\'                                 +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - LETTERS.SAV'                                             .

DATASET NAME Letters.
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |06-MAY-2011 19:58:34       |
|-----------------------------|---------------------------|
[Letters] C:\Documents and Settings\Richard\My Documents
             \Technical\spssx-l\Z-2011\
             2011-05-05 UMD_user - Re-Saving the results of Match
files - LETTERS.SAV

Alphabet Order RomanLtr GreekLtr HebrwLtr

Roman       1  A        Alpha    Aleph
Roman       2  B        Beta     Beth
Roman       3  C        Gamma    Gimel
Roman       4  D        Delta    Daleth

Number of cases read:  4    Number of cases listed:  4


SORT CASES BY RomanLtr.
/*--  DATASET DISPLAY /*-*/.


MATCH FILES /FILE = Names
    /TABLE = Letters
    /BY RomanLtr.

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |06-MAY-2011 19:58:35       |
|-----------------------------|---------------------------|
RomanLtr Name     Family   Alphabet Order GreekLtr HebrwLtr

A        Aaron    Watson   Roman       1  Alpha    Aleph
A        Alice    Urban    Roman       1  Alpha    Aleph
A        Andrew   Vance    Roman       1  Alpha    Aleph
B        Betty    Williams Roman       2  Beta     Beth
B        Bill     Ulam     Roman       2  Beta     Beth

Number of cases read:  5    Number of cases listed:  5


DATASET NAME MERGED WINDOW=FRONT.
/*--  DATASET DISPLAY /*-*/.

SAVE OUTFILE=
         'C:\Documents and Settings\Richard\My Documents'             +
         '\Temporary\SPSS\'                                           +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - MERGED.SAV'                                             .

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |06-MAY-2011 19:58:35       |
|-----------------------------|---------------------------|
[MERGED] C:\Documents and Settings\Richard\My Documents
            \Temporary\SPSS\
            2011-05-05 UMD_user - Re-Saving the results of Match
files - MERGED.SAV

RomanLtr Name     Family   Alphabet Order GreekLtr HebrwLtr

A        Aaron    Watson   Roman       1  Alpha    Aleph
A        Alice    Urban    Roman       1  Alpha    Aleph
A        Andrew   Vance    Roman       1  Alpha    Aleph
B        Betty    Williams Roman       2  Beta     Beth
B        Bill     Ulam     Roman       2  Beta     Beth

Number of cases read:  5    Number of cases listed:  5


GET FILE=
         'C:\Documents and Settings\Richard\My Documents'             +
         '\Temporary\SPSS\'                                           +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - MERGED.SAV'                                             .
DATASET NAME Reload.
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |06-MAY-2011 19:58:36       |
|-----------------------------|---------------------------|
[Reload]

RomanLtr Name     Family   Alphabet Order GreekLtr HebrwLtr

A        Aaron    Watson   Roman       1  Alpha    Aleph
A        Alice    Urban    Roman       1  Alpha    Aleph
A        Andrew   Vance    Roman       1  Alpha    Aleph
B        Betty    Williams Roman       2  Beta     Beth
B        Bill     Ulam     Roman       2  Beta     Beth


Number of cases read:  5    Number of cases listed:  5
=====================================
Code -- test data created separately.
(Will send on request)
=====================================
*  C:\Documents and Settings\Richard\My Documents                    .
*    \Technical\spssx-l\Z-2011\                                      .
*    2011-05-05 UMD_user - Re-Saving the results of Match files.SPS  .

*  In response to posting                                            .
*  Date:    Thu, 5 May 2011 07:08:55 -0700                           .
*  From:    UMD_user <[hidden email]>                             .
*  Subject: Re: Saving the results of Match files                    .
*  To:      [hidden email]                                 .
*    original posting                                                .
*  Date:    Wed, 4 May 2011 11:24:07 -0700                           .

*  From original post:                                               .
*  "I match two [datasets] files and this produces an entirely new   .
*  file that shows as an unnamed dataset. I attempt to save this     .
*  new, unnamed dataset...however, when I do, SPSS looks at what it  .
*  considers the "active" dataset (COMPFALL10) and instead saves     .
*  this file and closes my newly created unnamed dataset."           .
*  From this one:                                                    .
*  "I tried adding DATASET NAME MERGED WINDOW=FRONT after the merge  .
*  but unfortunately that did not work either (per below). SPSS      .
*  closed my new file and just renamed the COMPFALL10 file as        .
*  MERGED. This definitely does seem to be a bug. I am entirely      .
*  using syntax...nothing from the menus to generate the code."      .

*  This is not the posted syntax, but is written to follow its logic .
*  and structure as closely as possible:                             .

GET FILE=
       'C:\Documents and Settings\Richard\My Documents'               +
         '\Technical\spssx-l\Z-2011\'                                 +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - NAMES.SAV'.

DATASET NAME Names.
LIST.
SORT CASES BY RomanLtr.


GET FILE=
       'C:\Documents and Settings\Richard\My Documents'               +
         '\Technical\spssx-l\Z-2011\'                                 +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - LETTERS.SAV'                                             .

DATASET NAME Letters.
LIST.
SORT CASES BY RomanLtr.


/*--  DATASET DISPLAY /*-*/.


MATCH FILES /FILE = Names
    /TABLE = Letters
    /BY RomanLtr.

LIST.

DATASET NAME MERGED WINDOW=FRONT.

/*--  DATASET DISPLAY /*-*/.

SAVE OUTFILE=
         'C:\Documents and Settings\Richard\My Documents'             +
         '\Temporary\SPSS\'                                           +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - MERGED.SAV'                                             .

LIST.

GET FILE=
         'C:\Documents and Settings\Richard\My Documents'             +
         '\Temporary\SPSS\'                                           +
         '2011-05-05 UMD_user - Re-Saving the results of Match files' +
         ' - MERGED.SAV'                                             .
DATASET NAME Reload.
LIST.







>GET FILE = 'U:\Sample syntax\Fall 10 Day Nonreturnee Comparison.sav'.
>DATASET NAME COMPFALL10.
>SORT CASES BY EMPLID.
>
>GET FILE = 'X:\SPSS Documents\Enrollment\UNDUP ENR FALL 10.SAV'.
>DATASET NAME UNDUPFALL10.
>SORT CASES BY EMPLID.
>
>MATCH FILES /FILE = COMPFALL10
>    /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
>    /TABLE = UNDUPFALL10
>    /BY EMPLID
>    /KEEP = EMPLID SEX AGE_OCT ETHNIC_FED RESCD ACAD_PLAN_FALL ACADPLAN
>CUMGPA.
>EXECUTE.
>
>DATASET NAME MERGED WINDOW=FRONT.
>
>SAVE OUTFILE='U:\Sample syntax\Fall 10 Day Nonreturnee Comparison_1.sav'
>   /COMPRESSED.
>
>--
>View this message in context:
>http://spssx-discussion.1045642.n5.nabble.com/Saving-the-results-of-Match-files-tp4370649p4372888.html
>Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
>=====================
>To manage your subscription to SPSSX-L, send a message to
>[hidden email] (not to SPSSX-L), with no body text except the
>command. To leave the list, send the command
>SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
>INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

UMD_user
I tested the syntax again using your suggested coding (I am working off of PASW statistics 18). It did work fine. I also went back and tested my own code and that worked fine as well. I believe my problem may have been something as simple as not running all of the code in sequence all at the same time. I may have "checked" that things were working as planned in my initial runs by running the code in segments. This likely altered what was and wasn't considered to be the active dataset. Still, without the addition of the command DATASET NAME MERGED WINDOW=FRONT it never would have worked properly even if I had not run the code in segments. So, that seems to be the key workaround needed. Appreciate all of the good insight!
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Melissa Ives
In reply to this post by UMD_user
I have this same problem.
When running a merge syntax (from syntax not dialog boxes), the newly created file is not set as the active dataset (i.e. the red '+' remains in the older file).

My experience has been:
A) If I just run the match with an immediate dataset name AND the match results in an error, then my original file is renamed (NOT what you want).  I have actually had the old file get renamed and the new file disappear.
B) If I run the match without an immediate dataset name, then confirm that the match ran correctly, I cannot run the dataset name command without first clicking onto the newly matched file to set it as active (NOT productive).
C) If I run a match file that includes \in=varname for both files, followed immediately by a crosstab of the two 'in' variables to force a data pass/run the match, the newly matched file disappears because it is not the active file and it is not named and the crosstab results in an error.

Maybe everyone else never has a match go wrong, but now I always run the syntax slowly and in sections to assure that the right file gets the dataset name and unnamed files don't end up simply disappearing because they were not set as the active file.

Melissa


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of UMD_user
Sent: Thursday, May 05, 2011 9:09 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Saving the results of Match files

I tried adding the DATASET NAME MERGED WINDOW=FRONT command line after the merge but unfortunately that did not work either (per below). SPSS closed my new file and just renamed the COMPFALL10 file as MERGED. This definitely does seem to be a bug. I am entirely using syntax...nothing from the menus to generate the code.

GET FILE = 'U:\Sample syntax\Fall 10 Day Nonreturnee Comparison.sav'.
DATASET NAME COMPFALL10.
SORT CASES BY EMPLID.

GET FILE = 'X:\SPSS Documents\Enrollment\UNDUP ENR FALL 10.SAV'.
DATASET NAME UNDUPFALL10.
SORT CASES BY EMPLID.

MATCH FILES /FILE = COMPFALL10
   /RENAME=(ACAD_PLAN1=ACAD_PLAN_FALL)
   /TABLE = UNDUPFALL10
   /BY EMPLID
   /KEEP = EMPLID SEX AGE_OCT ETHNIC_FED RESCD ACAD_PLAN_FALL ACADPLAN CUMGPA.
EXECUTE.

DATASET NAME MERGED WINDOW=FRONT.

SAVE OUTFILE='U:\Sample syntax\Fall 10 Day Nonreturnee Comparison_1.sav'
  /COMPRESSED.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Saving-the-results-of-Match-files-tp4370649p4372888.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Saving the results of Match files

Richard Ristow
At 02:19 PM 5/13/2011, Melissa Ives wrote:
\
>I have this same problem.

As I understand you, yours doesn't sound quite the same. I understood
the original poster to be having difficulties when a MATCH FILES
worked correctly. You've run into some glitches that (mostly) occur
when a MATCH FILES fails.

>When running a merge syntax (from syntax not dialog boxes), the
>newly created file is not set as the active dataset (i.e. the red
>'+' remains in the older file).

Right. When SPSS is running, it has *two* datasets that are
distinguished for processing; they may or may not be the same.
(Unfortunately, SPSS documentation refers to both kinds of
distinction as the dataset being 'active'.)

The first, for which I would reserve the word 'active', is the
dataset that SPSS commands act on. It is the only dataset that need
not have a name. Running the merge from syntax makes the newly
created dataset 'active' in THIS sense.

The second, which I would rather describe as 'foreground', is the
dataset whose window is in front. The menu system will give you
variables from this dataset, and otherwise treat it as the
distinguished one, during menu operations. Creating a dataset does
*not* put it in the 'foreground'.

A DATASET NAME command with WINDOWS=FRONT *does* put the dataset in
the foreground. (It's wise to put "WINDOWS=FRONT" on most DATASET
NAME and DATASET ACTIVATE commands, to ensure that the dataset is
'foreground' as well as 'active'.)

>My experience has been:
>A) If I just run the match with an [immediately following] DATASET
>NAME [command] AND the match results in an error, then my original
>file is renamed (NOT what you want).  I have actually had the old
>file get renamed and the new file disappear.

Right. A successful MATCH FILES leaves the new dataset active, and a
DATASET NAME will give the desired result. But if the match fails.
SPSS will report "this command not executed", leave the old
previously active dataset active, and a DATASET NAME command will
rename *that* file.

It's unfortunate that there's no good way to test for the success of
a previous completion of a file-creating command.

>B) If I run the match without an immediate dataset name, then
>confirm that the match ran correctly, I cannot run the dataset name
>command without first clicking onto the newly matched file to set it
>as active (NOT productive).

Right again. Again, this comes from the decision that a newly created
active dataset not automatically be put in the 'foreground'.
(Remember, SPSS documentation doesn't use the term 'foreground'; what
I'm calling 'foreground', it calls 'active'.)

>C) If I run a match file that includes \in=varname for both files,
>followed immediately by a crosstab of the two 'in' variables to
>force a data pass/run the match, the newly matched file disappears
>because it is not the active file and it is not named and the
>crosstab results in an error.

You mean, after a successful match? Do you have an example? Below in
this post is a very simple MATCH in SPSS 14. It seems to have worked,
including leaving the new, unnamed dataset active.

>Maybe everyone else never has a match go wrong, but now I always run
>the syntax slowly and in sections to assure that the right file gets
>the dataset name and unnamed files don't end up simply disappearing
>because they were not set as the active file.

Here's a workaround that should leave the merged file, or a copy of
one of the inputs, active under the name 'Merged', whether the match
succeeds or fails. Test data as for the test run mentioned above
(which follows):

DATASET ACTIVATE Personal WINDOW=FRONT.
DATASET COPY     Merged.
DATASET ACTIVATE Merged   WINDOW=FRONT.
MATCH FILES
   /FILE=*        /IN=HasFirst
   /FILE=Family   /IN=HasLast
   /BY Initial.

CROSSTABS TABLES=HasFirst BY HasLast.

Crosstabs
|-----------------------------|---------------------------|
|Output Created               |18-MAY-2011 17:36:33       |
|-----------------------------|---------------------------|
[Merged]

Case Processing Summary [suppressed]

HasFirst * HasLast Crosstabulation
Count
|--------|-|--------|-----|
|        | |HasLast |Total|
|        | |------|-|     |
|        | |0     |1|     |
|--------|-|------|-|-----|
|HasFirst|0|0     |1|1    |
|        |-|------|-|-----|
|        |1|1     |2|3    |
|--------|-|------|-|-----|
|Total     |1     |3|4    |
|----------|------|-|-----|


DATASET DISPLAY.

Dataset Display
|-----------------------------|---------------------------|
|Output Created               |18-MAY-2011 17:36:33       |
|-----------------------------|---------------------------|
Datasets
|---------|
|Personal |
|Family   |
|Merged(a)|
|---------|
a Active dataset


========
Test run
========
NEW FILE.
DATA LIST LIST /
   Initial   FName
   (A1,     A10).
BEGIN DATA.
A Aaron
C Charles
D Dorothy
END DATA.
DATASET NAME Personal.
NEW FILE.
DATA LIST LIST /
   Initial   LName
   (A1,     A10).
BEGIN DATA.
A Anderson
B Brigham
D DeWitt
END DATA.
DATASET NAME Family.
MATCH FILES
   /FILE=Personal /IN=HasFirst
   /FILE=Family   /IN=HasLast
   /BY Initial.

CROSSTABS TABLES=HasFirst BY HasLast.

Crosstabs
|-----------------------------|---------------------------|
|Output Created               |18-MAY-2011 14:17:09       |
|-----------------------------|---------------------------|
Case Processing Summary
|---------------|----------------------------------------|
|               |Cases                                   |
|               |------------|--------------|------------|
|               |Valid       |Missing       |Total       |
|               |----|-------|------|-------|----|-------|
|               |N   |Percent|N     |Percent|N   |Percent|
|---------------|----|-------|------|-------|----|-------|
|HasFirst *     |4   |100.0% |0     |.0%    |4   |100.0% |
|HasLast        |    |       |      |       |    |       |
|---------------|----|-------|------|-------|----|-------|

HasFirst * HasLast Crosstabulation
Count
|--------|-|--------|-----|
|        | |HasLast |Total|
|        | |------|-|     |
|        | |0     |1|     |
|--------|-|------|-|-----|
|HasFirst|0|0     |1|1    |
|        |-|------|-|-----|
|        |1|1     |2|3    |
|--------|-|------|-|-----|
|Total     |1     |3|4    |
|----------|------|-|-----|

DATASET DISPLAY.
|-----------------------------|---------------------------|
|Output Created               |18-MAY-2011 14:17:31       |
|-----------------------------|---------------------------|
Datasets
|------------|
|Personal    |
|------------|
|Family      |
|------------|
|(unnamed)(a)|
|------------|
a Active dataset






>Maybe everyone else never has a match go wrong, but now I always run
>the syntax slowly and in sections to assure that the right file gets
>the dataset name and unnamed files don't end up simply disappearing
>because they were not set as the active file.


APPENDIX: Test data and code
============================

NEW FILE.
DATA LIST LIST /
   Initial   FName
   (A1,     A10).
BEGIN DATA.
A Aaron
C Charles
D Dorothy
END DATA.
DATASET NAME Personal.
NEW FILE.
DATA LIST LIST /
   Initial   LName
   (A1,     A10).
BEGIN DATA.
A Anderson
B Brigham
D DeWitt
END DATA.
DATASET NAME Family.
MATCH FILES
   /FILE=Personal /IN=HasFirst
   /FILE=Family   /IN=HasLast
   /BY Initial.

CROSSTABS TABLES=HasFirst BY HasLast.

Crosstabs
|-----------------------------|---------------------------|
|Output Created               |18-MAY-2011 14:17:09       |
|-----------------------------|---------------------------|
Case Processing Summary
|---------------|----------------------------------------|
|               |Cases                                   |
|               |------------|--------------|------------|
|               |Valid       |Missing       |Total       |
|               |----|-------|------|-------|----|-------|
|               |N   |Percent|N     |Percent|N   |Percent|
|---------------|----|-------|------|-------|----|-------|
|HasFirst *     |4   |100.0% |0     |.0%    |4   |100.0% |
|HasLast        |    |       |      |       |    |       |
|---------------|----|-------|------|-------|----|-------|

HasFirst * HasLast Crosstabulation
Count
|--------|-|--------|-----|
|        | |HasLast |Total|
|        | |------|-|     |
|        | |0     |1|     |
|--------|-|------|-|-----|
|HasFirst|0|0     |1|1    |
|        |-|------|-|-----|
|        |1|1     |2|3    |
|--------|-|------|-|-----|
|Total     |1     |3|4    |
|----------|------|-|-----|



DATASET DISPLAY.

Dataset Display
|-----------------------------|---------------------------|
|Output Created               |18-MAY-2011 14:17:31       |
|-----------------------------|---------------------------|
Datasets
|------------|
|Personal    |
|------------|
|Family      |
|------------|
|(unnamed)(a)|
|------------|
a Active dataset

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD