Template Files in Macros

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

Template Files in Macros

Brian Dates
I have a macro that I use to direct storage and retrieval of files, which David submitted several years ago. Recently, I tried to use it to identify a template for a chart. This is a legacy line chart, not GPL, which I do know needs special attention when using macros. The macro is as follows:

define !path () "C:\SPSS syntax\specific measure analysis\cafas analysis\"
!enddefine .
 define !path2(name=!tokens(1) /extn=!tokens(1) !default(".sbs"))
 !quote(!concat(
 !unquote(!eval(!path)),
 !unquote(!name),
 !unquote(!extn)))
 !enddefine .

The graph specification is:

GRAPH
  /LINE(SIMPLE)=MEAN(values.3) BY TimeofMeasurement
  /TITLE='Mean CAFAS Total Score by Time of Measurement'
  /template=!path2 name="cafas scale graph" .

The Warning is #34. ">Warning # 34 in column 122.  Text: c:/spss syntax/specific measure analysis/cafas analysis/cafas graph.sgt 
>SPSS Statistics cannot access a file with the given file specification.  The
>file specification is either syntactically invalid, specifies an invalid
>drive, specifies a protected directory, specifies a protected file, or
>specifies a non-sharable file."

The syntax produces the graph. Why, if SPSS cannot access the file, is the correct graph produced? Second, if I copy and paste the template file into a path different from that in which I saved the original, the same Warning appears, even when I don't use a macro, and yet the correct graph appears. I'm curious as to why I'm told that the file cannot be accessed but the graph is produced.

Thanks!

Cheers.

Brian



Brian G. Dates, M.A.
Consultant in Program Evaluation, Research, and Statistics
248-229-2865
===================== 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: Template Files in Macros

Jon Peck
The error would only affect the use of the named template.  The procedure is treating this as a warning, and warnings do  not stop execution of a command.

If you want to be sure of the expanded syntax run SET MPRINT ON. before the GRAPH command.  I  notice also that your name spec does not have the .sgt  extension.
I would have expected that to cause an error, but GRAPH seems to have compensated for that.

On Thu, Nov 12, 2020 at 5:55 PM Brian Dates <[hidden email]> wrote:
I have a macro that I use to direct storage and retrieval of files, which David submitted several years ago. Recently, I tried to use it to identify a template for a chart. This is a legacy line chart, not GPL, which I do know needs special attention when using macros. The macro is as follows:

define !path () "C:\SPSS syntax\specific measure analysis\cafas analysis\"
!enddefine .
 define !path2(name=!tokens(1) /extn=!tokens(1) !default(".sbs"))
 !quote(!concat(
 !unquote(!eval(!path)),
 !unquote(!name),
 !unquote(!extn)))
 !enddefine .

The graph specification is:

GRAPH
  /LINE(SIMPLE)=MEAN(values.3) BY TimeofMeasurement
  /TITLE='Mean CAFAS Total Score by Time of Measurement'
  /template=!path2 name="cafas scale graph" .

The Warning is #34. ">Warning # 34 in column 122.  Text: c:/spss syntax/specific measure analysis/cafas analysis/cafas graph.sgt 
>SPSS Statistics cannot access a file with the given file specification.  The
>file specification is either syntactically invalid, specifies an invalid
>drive, specifies a protected directory, specifies a protected file, or
>specifies a non-sharable file."

The syntax produces the graph. Why, if SPSS cannot access the file, is the correct graph produced? Second, if I copy and paste the template file into a path different from that in which I saved the original, the same Warning appears, even when I don't use a macro, and yet the correct graph appears. I'm curious as to why I'm told that the file cannot be accessed but the graph is produced.

Thanks!

Cheers.

Brian



Brian G. Dates, M.A.
Consultant in Program Evaluation, Research, and Statistics
248-229-2865
===================== 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: Template Files in Macros

bdates
Jon,

Thanks. The .sbs was a typo. Sorry.

I am curious, however, as to why a .sav file is fine with the macro, but not a .sgt. Is it true that even the old legacies can't accommodate a macro inside a command?

Brian

From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Thursday, November 12, 2020 8:49 PM
To: [hidden email] <[hidden email]>
Subject: Re: Template Files in Macros
 
The error would only affect the use of the named template.  The procedure is treating this as a warning, and warnings do  not stop execution of a command.

If you want to be sure of the expanded syntax run SET MPRINT ON. before the GRAPH command.  I  notice also that your name spec does not have the .sgt  extension.
I would have expected that to cause an error, but GRAPH seems to have compensated for that.

On Thu, Nov 12, 2020 at 5:55 PM Brian Dates <[hidden email]> wrote:
I have a macro that I use to direct storage and retrieval of files, which David submitted several years ago. Recently, I tried to use it to identify a template for a chart. This is a legacy line chart, not GPL, which I do know needs special attention when using macros. The macro is as follows:

define !path () "C:\SPSS syntax\specific measure analysis\cafas analysis\"
!enddefine .
 define !path2(name=!tokens(1) /extn=!tokens(1) !default(".sbs"))
 !quote(!concat(
 !unquote(!eval(!path)),
 !unquote(!name),
 !unquote(!extn)))
 !enddefine .

The graph specification is:

GRAPH
  /LINE(SIMPLE)=MEAN(values.3) BY TimeofMeasurement
  /TITLE='Mean CAFAS Total Score by Time of Measurement'
  /template=!path2 name="cafas scale graph" .

The Warning is #34. ">Warning # 34 in column 122.  Text: c:/spss syntax/specific measure analysis/cafas analysis/cafas graph.sgt 
>SPSS Statistics cannot access a file with the given file specification.  The
>file specification is either syntactically invalid, specifies an invalid
>drive, specifies a protected directory, specifies a protected file, or
>specifies a non-sharable file."

The syntax produces the graph. Why, if SPSS cannot access the file, is the correct graph produced? Second, if I copy and paste the template file into a path different from that in which I saved the original, the same Warning appears, even when I don't use a macro, and yet the correct graph appears. I'm curious as to why I'm told that the file cannot be accessed but the graph is produced.

Thanks!

Cheers.

Brian



Brian G. Dates, M.A.
Consultant in Program Evaluation, Research, and Statistics
248-229-2865
===================== 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
===================== 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: Template Files in Macros

Jon Peck
Macro expansion takes place before the syntax is passed to any command or procedure.  The macro processor knows nothing about specific commands, although text that is not in the standard
SPSS form such as GPL or Python or  R programmability code does not sit well with the macro processor.  The warning you are getting
comes from the GRAPH parse of the expanded commands, which is why I suggested  doing SET MPRINT ON to see what GRAPH sees.  
It is up to  the procedure to raise an error or warning and handle it, including stopping the command.  For GRAPH, apparently the missing template
file is not serious enough to  stop the command.

On Fri, Nov 13, 2020 at 8:13 AM Dates, Brian <[hidden email]> wrote:
Jon,

Thanks. The .sbs was a typo. Sorry.

I am curious, however, as to why a .sav file is fine with the macro, but not a .sgt. Is it true that even the old legacies can't accommodate a macro inside a command?

Brian

From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Thursday, November 12, 2020 8:49 PM
To: [hidden email] <[hidden email]>
Subject: Re: Template Files in Macros
 
The error would only affect the use of the named template.  The procedure is treating this as a warning, and warnings do  not stop execution of a command.

If you want to be sure of the expanded syntax run SET MPRINT ON. before the GRAPH command.  I  notice also that your name spec does not have the .sgt  extension.
I would have expected that to cause an error, but GRAPH seems to have compensated for that.

On Thu, Nov 12, 2020 at 5:55 PM Brian Dates <[hidden email]> wrote:
I have a macro that I use to direct storage and retrieval of files, which David submitted several years ago. Recently, I tried to use it to identify a template for a chart. This is a legacy line chart, not GPL, which I do know needs special attention when using macros. The macro is as follows:

define !path () "C:\SPSS syntax\specific measure analysis\cafas analysis\"
!enddefine .
 define !path2(name=!tokens(1) /extn=!tokens(1) !default(".sbs"))
 !quote(!concat(
 !unquote(!eval(!path)),
 !unquote(!name),
 !unquote(!extn)))
 !enddefine .

The graph specification is:

GRAPH
  /LINE(SIMPLE)=MEAN(values.3) BY TimeofMeasurement
  /TITLE='Mean CAFAS Total Score by Time of Measurement'
  /template=!path2 name="cafas scale graph" .

The Warning is #34. ">Warning # 34 in column 122.  Text: c:/spss syntax/specific measure analysis/cafas analysis/cafas graph.sgt 
>SPSS Statistics cannot access a file with the given file specification.  The
>file specification is either syntactically invalid, specifies an invalid
>drive, specifies a protected directory, specifies a protected file, or
>specifies a non-sharable file."

The syntax produces the graph. Why, if SPSS cannot access the file, is the correct graph produced? Second, if I copy and paste the template file into a path different from that in which I saved the original, the same Warning appears, even when I don't use a macro, and yet the correct graph appears. I'm curious as to why I'm told that the file cannot be accessed but the graph is produced.

Thanks!

Cheers.

Brian



Brian G. Dates, M.A.
Consultant in Program Evaluation, Research, and Statistics
248-229-2865
===================== 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


--
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: Template Files in Macros

bdates
Jon,

Thanks. I'll look at SET MPRINT ON.

Brian

From: Jon Peck <[hidden email]>
Sent: Friday, November 13, 2020 10:21 AM
To: Dates, Brian <[hidden email]>
Cc: [hidden email] <[hidden email]>
Subject: Re: Template Files in Macros
 
Macro expansion takes place before the syntax is passed to any command or procedure.  The macro processor knows nothing about specific commands, although text that is not in the standard
SPSS form such as GPL or Python or  R programmability code does not sit well with the macro processor.  The warning you are getting
comes from the GRAPH parse of the expanded commands, which is why I suggested  doing SET MPRINT ON to see what GRAPH sees.  
It is up to  the procedure to raise an error or warning and handle it, including stopping the command.  For GRAPH, apparently the missing template
file is not serious enough to  stop the command.

On Fri, Nov 13, 2020 at 8:13 AM Dates, Brian <[hidden email]> wrote:
Jon,

Thanks. The .sbs was a typo. Sorry.

I am curious, however, as to why a .sav file is fine with the macro, but not a .sgt. Is it true that even the old legacies can't accommodate a macro inside a command?

Brian

From: SPSSX(r) Discussion <[hidden email]> on behalf of Jon Peck <[hidden email]>
Sent: Thursday, November 12, 2020 8:49 PM
To: [hidden email] <[hidden email]>
Subject: Re: Template Files in Macros
 
The error would only affect the use of the named template.  The procedure is treating this as a warning, and warnings do  not stop execution of a command.

If you want to be sure of the expanded syntax run SET MPRINT ON. before the GRAPH command.  I  notice also that your name spec does not have the .sgt  extension.
I would have expected that to cause an error, but GRAPH seems to have compensated for that.

On Thu, Nov 12, 2020 at 5:55 PM Brian Dates <[hidden email]> wrote:
I have a macro that I use to direct storage and retrieval of files, which David submitted several years ago. Recently, I tried to use it to identify a template for a chart. This is a legacy line chart, not GPL, which I do know needs special attention when using macros. The macro is as follows:

define !path () "C:\SPSS syntax\specific measure analysis\cafas analysis\"
!enddefine .
 define !path2(name=!tokens(1) /extn=!tokens(1) !default(".sbs"))
 !quote(!concat(
 !unquote(!eval(!path)),
 !unquote(!name),
 !unquote(!extn)))
 !enddefine .

The graph specification is:

GRAPH
  /LINE(SIMPLE)=MEAN(values.3) BY TimeofMeasurement
  /TITLE='Mean CAFAS Total Score by Time of Measurement'
  /template=!path2 name="cafas scale graph" .

The Warning is #34. ">Warning # 34 in column 122.  Text: c:/spss syntax/specific measure analysis/cafas analysis/cafas graph.sgt 
>SPSS Statistics cannot access a file with the given file specification.  The
>file specification is either syntactically invalid, specifies an invalid
>drive, specifies a protected directory, specifies a protected file, or
>specifies a non-sharable file."

The syntax produces the graph. Why, if SPSS cannot access the file, is the correct graph produced? Second, if I copy and paste the template file into a path different from that in which I saved the original, the same Warning appears, even when I don't use a macro, and yet the correct graph appears. I'm curious as to why I'm told that the file cannot be accessed but the graph is produced.

Thanks!

Cheers.

Brian



Brian G. Dates, M.A.
Consultant in Program Evaluation, Research, and Statistics
248-229-2865
===================== 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


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