Discussion:
Keep Subcommand not working....
(too old to reply)
m***@gmail.com
2006-03-15 21:40:49 UTC
Permalink
Hello all, I'm relatively new to SPSS syntax, I've been teaching myself
based off posts from this group and some computer programming skills
i've picked up... anywho..
I transfered some syntax from SPSS 8.0 to SPSS 11.0 (and i included the
data file too ;-)) below is the syntax

get file='C:\Documents and Settings\psyc-ga\Desktop\SPSS
Syntax\test3.sav'.
/KEEP
id# Clinid# Case# TSERVHR TXLENGTH TXDOSE CTNSWTM CTNSWIND
THNSWTM THNSWING CTCANTM CTCANIND THCANTM THCANIND UNCONTM
UNCONND.

SAVE OUTFILE='C:\Documents and
Settings\asburkley0\Desktop\Util_tab1.sav'
/COMPRESSED.

however when I ran the syntax in SPSS 11.0 the output stated
Error # 1. Command name: /KEEP
The first word in the line is not recognized as an SPSS command.
This command not executed.
So WTF? lol I thought KEEP was a subcommand in SPSS 11.0 too?? (btw
the data has over 1000 variables so it'd be nice to sort out the ones i
want) THANKS A BUNCH!

~D.B.
w***@odjfs.state.oh.us
2006-03-15 21:48:07 UTC
Permalink
Hi,
Try this:

get file='C:\Documents and Settings\psyc-ga\Desktop\SPSS
Syntax\test3.sav' /KEEP
id# Clinid# Case# TSERVHR TXLENGTH TXDOSE CTNSWTM CTNSWIND
THNSWTM THNSWING CTCANTM CTCANIND THCANTM THCANIND UNCONTM
UNCONND.

The trick is to remove the period after test3.sav'. KEEP is a
subcommand.
m***@gmail.com
2006-03-15 21:54:08 UTC
Permalink
DAH! Such a Simple Mistake... THANKS!!!!!!!!!!!!!!
Luca Hartman
2023-10-05 15:22:26 UTC
Permalink
Hi... could you be of help?

I am having the same issue, here is my syntax:

write out="Data Outfiles/Temp/OutcomesFileName baseline.sps"
/" save outfile='Data Outfiles\Outcomes 22-23 baseline. Generated ", Years, ".", Months, ".", Days, ".sav' ".
write out="Data Outfiles\Temp\OutcomesFileName baseline.sps"
/ "/KEEP ID Date OQSymptomDistress OQInterpersonalRel OQSocialRole OQTotal ".
Error # 1. Command name: /KEEP
The first word in the line is not recognized as an SPSS command.
This command not executed.
Any clue what the issue may be?
Rich Ulrich
2023-10-06 01:00:28 UTC
Permalink
On Thu, 5 Oct 2023 08:22:26 -0700 (PDT), Luca Hartman
Post by Luca Hartman
Hi... could you be of help?
write out="Data Outfiles/Temp/OutcomesFileName baseline.sps"
/" save outfile='Data Outfiles\Outcomes 22-23 baseline. Generated ", Years, ".", Months, ".", Days, ".sav' ".
write out="Data Outfiles\Temp\OutcomesFileName baseline.sps"
/ "/KEEP ID Date OQSymptomDistress OQInterpersonalRel OQSocialRole OQTotal ".
Error # 1. Command name: /KEEP
The first word in the line is not recognized as an SPSS command.
This command not executed.
Any clue what the issue may be?
First: The Subject line does not fit the question, if you are
intending to write those lines to a file - which is what your WRITE
does.
https://www.ibm.com/docs/en/spss-statistics/29.0.0?topic=write-overview-command

Second: I have used < Write out = ... > a lot, but I think
that I have never tried to give the same file name for
two "Write" commands. I suspect that it tried to open
the file as a separate file from the first one, which would
not be useful. And should generate some error message.
(If I'm wrong ... then it is a mystery.)

So. I guess the message that you see is not apt, but I suspect
that two Write's with the same out= is what leads to it.

In any case, you do not NEED a second Write command. You
can write two lines by putting in a "/" to ask for a new line.

So. Replace the "." at the end of the first written-out line
with a blank and delete the second "write out=" line . Your
"/KEEP line already starts with a "/".
--
Rich Ulrich
Loading...