Insert in Define

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

Insert in Define

Stan Gorodenski
In the syntax below I open USERTEMPS/TMP3 with a GET FILE statement.
Following the GET FILE statement I have an INSERT statement to insert a
fairly long set of SPSS syntax. I only want to execute the GET FILE and
execute INSERT if a certain condition is met. The following shows what I
am attempting to do.
DEFINE !DATCHECK (ARG1 = !TOKENS(1))
   !IF (!ARG1 !GT 2) !THEN
     GET FILE 'USERTEMPS/TMP3'.
     INSERT FILE = 'INSERTS/DataCheck.sps'.
   !IFEND
!ENDDEFINE.
!DATCHECK ARG1=4.

I know the 'GET FILE' statement works within the !IF - !IFEND loop
because I had put in a DISPLAY DICTIONARY command to see if it does. The
INSERT FILE command does not work because SPSS says it does not work in
a loop, or something to that effect. I also tried INCLUDE FILE and it
did not work for the same reason.

!DATCHECK works if I toss the !IF - !IFEND conditional statements, but
not with them. Is there another way to do what I want?
Stan

=====================
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: Insert in Define

Jon Peck
It appears that the first command in the inserted file is being ignored.  Try making the first line
comment "this line is ignored".


On Thu, Oct 31, 2019 at 10:51 PM Stan Gorodenski <[hidden email]> wrote:
In the syntax below I open USERTEMPS/TMP3 with a GET FILE statement.
Following the GET FILE statement I have an INSERT statement to insert a
fairly long set of SPSS syntax. I only want to execute the GET FILE and
execute INSERT if a certain condition is met. The following shows what I
am attempting to do.
DEFINE !DATCHECK (ARG1 = !TOKENS(1))
   !IF (!ARG1 !GT 2) !THEN
     GET FILE 'USERTEMPS/TMP3'.
     INSERT FILE = 'INSERTS/DataCheck.sps'.
   !IFEND
!ENDDEFINE.
!DATCHECK ARG1=4.

I know the 'GET FILE' statement works within the !IF - !IFEND loop
because I had put in a DISPLAY DICTIONARY command to see if it does. The
INSERT FILE command does not work because SPSS says it does not work in
a loop, or something to that effect. I also tried INCLUDE FILE and it
did not work for the same reason.

!DATCHECK works if I toss the !IF - !IFEND conditional statements, but
not with them. Is there another way to do what I want?
Stan

=====================
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


--
Jon K Peck
[hidden email]

===================== 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: Insert in Define

Stan Gorodenski
Jon,
I already had a first line that was a comment in the inserted file, but
I added the comment you suggested. It still will not run. Below is the
output that gives the errors. After running the macro and getting these
error messages, I deleted the !IF - !THEN and !IFEND statements and ran
it again and it works. I then went back and added the conditional
statements and it won't work, i.e., I get the same error messages below.
Stan

DEFINE !DATCHECK (ARG1 = !TOKENS(1))
!IF (!ARG1 !GT 2) !THEN
     GET FILE 'USERTEMPS/TMP3'.
     INSERT FILE = 'INSERTS/DataCheck.sps'.
!IFEND
!ENDDEFINE.
!DATCHECK ARG1=4.
  487  0  *this line is ignored.
  488  0  * One way of renaming variables. Cannot get VAR00X to work in
the Macro graph routine.
  488  0    COMPUTE V1_TO_VN = $CASENUM.
  489  0    EXECUTE.

Preceding task required .00 seconds CPU time;  .00 seconds elapsed.

  490  0    AGGREGATE OUT *
  491  0      / PRESORTED
  492  0      / BREAK V1_TO_VN
  493  0      / V1 TO V100 = MAX(VAR001 TO VAR100).

Error # 10934 on line 492 in column 10.  Text: V1_TO_VN
The AGGREGATE command specifies an unknown existing variable name.
Execution of this command stops.

Preceding task required .00 seconds CPU time;  .00 seconds elapsed.

  494  0
  495  0  * Generating all graphs if desired. Change the MACRO arguments
to narrow the selection.

=====================
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: Insert in Define

Jon Peck
I wanted you to use the COMMENT command, not *.  It appears that the COMPUTE was skipped.

On Fri, Nov 1, 2019 at 12:18 PM Stan Gorodenski <[hidden email]> wrote:
Jon,
I already had a first line that was a comment in the inserted file, but
I added the comment you suggested. It still will not run. Below is the
output that gives the errors. After running the macro and getting these
error messages, I deleted the !IF - !THEN and !IFEND statements and ran
it again and it works. I then went back and added the conditional
statements and it won't work, i.e., I get the same error messages below.
Stan

DEFINE !DATCHECK (ARG1 = !TOKENS(1))
!IF (!ARG1 !GT 2) !THEN
     GET FILE 'USERTEMPS/TMP3'.
     INSERT FILE = 'INSERTS/DataCheck.sps'.
!IFEND
!ENDDEFINE.
!DATCHECK ARG1=4.
  487  0  *this line is ignored.
  488  0  * One way of renaming variables. Cannot get VAR00X to work in
the Macro graph routine.
  488  0    COMPUTE V1_TO_VN = $CASENUM.
  489  0    EXECUTE.

Preceding task required .00 seconds CPU time;  .00 seconds elapsed.

  490  0    AGGREGATE OUT *
  491  0      / PRESORTED
  492  0      / BREAK V1_TO_VN
  493  0      / V1 TO V100 = MAX(VAR001 TO VAR100).

Error # 10934 on line 492 in column 10.  Text: V1_TO_VN
The AGGREGATE command specifies an unknown existing variable name.
Execution of this command stops.

Preceding task required .00 seconds CPU time;  .00 seconds elapsed.

  494  0
  495  0  * Generating all graphs if desired. Change the MACRO arguments
to narrow the selection.

=====================
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


--
Jon K Peck
[hidden email]

===================== 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: Insert in Define

Stan Gorodenski
Jon,
I just tried it. Even using the command 'COMMENT this line is ignored.'
it still will not work. I get the same error messages.
Stan

where the GET FILE is before the macro, it is when the INSERT statement
is the only one in the macro, that is when I get the error message
On 11/1/2019 11:58 AM, Jon Peck wrote:

> I wanted you to use the COMMENT command, not *.  It appears that the
> COMPUTE was skipped.
>
> On Fri, Nov 1, 2019 at 12:18 PM Stan Gorodenski <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Jon,
>     I already had a first line that was a comment in the inserted
>     file, but
>     I added the comment you suggested. It still will not run. Below is
>     the
>     output that gives the errors. After running the macro and getting
>     these
>     error messages, I deleted the !IF - !THEN and !IFEND statements
>     and ran
>     it again and it works. I then went back and added the conditional
>     statements and it won't work, i.e., I get the same error messages
>     below.
>     Stan
>
>     DEFINE !DATCHECK (ARG1 = !TOKENS(1))
>     !IF (!ARG1 !GT 2) !THEN
>          GET FILE 'USERTEMPS/TMP3'.
>          INSERT FILE = 'INSERTS/DataCheck.sps'.
>     !IFEND
>     !ENDDEFINE.
>     !DATCHECK ARG1=4.
>       487  0  *this line is ignored.
>       488  0  * One way of renaming variables. Cannot get VAR00X to
>     work in
>     the Macro graph routine.
>       488  0    COMPUTE V1_TO_VN = $CASENUM.
>       489  0    EXECUTE.
>
>     Preceding task required .00 seconds CPU time;  .00 seconds elapsed.
>
>       490  0    AGGREGATE OUT *
>       491  0      / PRESORTED
>       492  0      / BREAK V1_TO_VN
>       493  0      / V1 TO V100 = MAX(VAR001 TO VAR100).
>
>     Error # 10934 on line 492 in column 10.  Text: V1_TO_VN
>     The AGGREGATE command specifies an unknown existing variable name.
>     Execution of this command stops.
>
>     Preceding task required .00 seconds CPU time;  .00 seconds elapsed.
>
>       494  0
>       495  0  * Generating all graphs if desired. Change the MACRO
>     arguments
>     to narrow the selection.
>
>     =====================
>     To manage your subscription to SPSSX-L, send a message to
>     [hidden email] <mailto:[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
>
>
>
> --
> Jon K Peck
> [hidden email] <mailto:[hidden email]>
>
> ===================== To manage your subscription to SPSSX-L, send a
> message to [hidden email]
> <mailto:[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