Problem with GGRAPH inside a macro (SPSS 17 freezes)

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

Problem with GGRAPH inside a macro (SPSS 17 freezes)

Marta Garcia-Granero
Hi

The following code (at the end of my message) is part of the process of writing a macro (for meta-analysis). Since the trickiest part (at least for me) is making GGRAPH&GPL work inside a macro (I have learned a bit thanks to ViAnn), I wrote a tiny macro to make sure that the adaptation of the GGRAPH code to the macro was correct. This piece of code works flawlessly in SPSS 15, but hangs miserably in SPSS 17. The log shows "_SLINE OFF." and then I see (status bar) "Running (in Spanish what I really see: "En ejecución") INLINE>...", and then SPSS freezes, and I can't exit the program, unless I manually run "END GPL.". Then I get this error message:

Advertencia
Error de GPL: algebra(pe_SLINEOFF._SLINE292.BEGINGPL)
Undefined com.spss.gpl.syntax.A.I: pe_SLINEOFF._SLINE292.BEGINGPL
GPL:
 SOURCE: s=userSource(id( "graphdataset" )) DATA: study=col(source(s), name( "study" ), unit.category()) DATA: ciup=col(source(s), name( "ciup" )) DATA: cilow=col(source(s), name( "cilow" )) DATA: measure=col(source(s), name( "measure" )) DATA: pe_SLINE OFF.
_SLINE 29 2.
BEGIN GPL
 SOURCE: s=userSource(id(!gdataset))
 DATA: study=col(source(s), name(!study), unit.category())
 DATA: ciup=col(source(s), name(!ciup))
 DATA: cilow=col(source(s), name(!cilow))
 DATA: measure=col(source(s), name(!measure))
 DATA: percwi=col(source(s), name(!percwi))
 GUIDE: text.title(label(!title))
 SCALE: cat(dim(1))
 SCALE: log(dim(2))
 COORD: rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))), shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
El comando no puede ejecutarse.


Any ideas?

Marta

This is the "offending" code:

* Sample dataset *.
DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow ciup percwi(5 F8.3).
BEGIN DATA
 1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
 2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
 3 1997 Gagnon    .867 .211 .573 1.311  12.237
 4 1989 Hodnett   .502 .332 .262  .962   4.940
 5 1991 Kennell   .352 .250 .216  .575   8.694
 6 1998 Langer    .280 .162 .203  .384  20.654
 7 ---- Total     .594 .074 .514  .687 100.000
END DATA.
SORT CASES BY trial(D).
VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR' /percwi'Weights(%)'.

* Macro definition *.
DEFINE MYGRAPH ().
!LET !title=!CONCAT('"','Fixed Effects Model','"').
!LET !template=!CONCAT('"','C:\Temp\Forest1.sgt','"').
!LET !gdataset=!CONCAT('"','graphdataset','"').
!LET !study=!CONCAT('"','study','"').
!LET !ciup=!CONCAT('"','ciup','"').
!LET !cilow=!CONCAT('"','cilow','"').
!LET !measure=!CONCAT('"','measure','"').
!LET !percwi=!CONCAT('"','percwi','"').

GGRAPH
  /GRAPHDATASET NAME=!gdataset VARIABLES=study ciup cilow measure percwi
  MISSING=LISTWISE REPORTMISSING=NO
 /GRAPHSPEC SOURCE=INLINE TEMPLATE=!template.
BEGIN GPL
 SOURCE: s=userSource(id(!gdataset))
 DATA:   study=col(source(s),   name(!study), unit.category())
 DATA:   ciup=col(source(s),    name(!ciup))
 DATA:   cilow=col(source(s),   name(!cilow))
 DATA:   measure=col(source(s), name(!measure))
 DATA:   percwi=col(source(s),  name(!percwi))
 GUIDE:  text.title(label(!title))
 SCALE:  cat(dim(1))
 SCALE:  log(dim(2))
 COORD:  rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))), shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
END GPL.
!ENDDEFINE.

* Macro call *.
MYGRAPH.

This is the content of the chart template "Forest1.sgt" the GGRAPH uses:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<template SPSS-Version="2.2" selectPath="87 2 30 97 98 12 13 900 "
xmlns="http://xml.spss.com/spss/visualization"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xml.spss.com/spss/visualization
http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">
 <setAxisStyle categorical="true" role="x">
  <label>Study name</label>
  <style color="#000000" stroke-width="0.5pt" visible="true"/>
 </setAxisStyle>
 <setAxisStyle categorical="false" role="y">
  <label> Favours treatment                 Favours Control</label>
  <style color="#000000" stroke-width="0.5pt" visible="true"/>
 </setAxisStyle>
 <addFrame count="1" type="visualization">
  <location bottom="556px" left="0px" right="433px" top="0px"/>
  <style color="#ffffff" color2="transparent" number="0" visible="true"/>
  <style font-family="SansSerif" font-size="8pt" number="1" pattern="0" stroke-linecap="butt" text-fit="true" visible="true"/>
 </addFrame>
 <addReferenceLine styleOnly="false" y="1.0" ycategorical="false">
  <style stroke-dasharray="3px,2px" visible="true" width="1pt"/>
 </addReferenceLine>
 <addFrame count="1" styleOnly="true" type="legend">
  <style color="transparent" color2="transparent" visible="false"/>
  <style color="transparent" color2="transparent" number="0" visible="false"/>
 </addFrame>
 <addFrame count="1" styleOnly="true" type="graph">
  <style color="transparent" color2="transparent" visible="true"/>
  <style color="#f0f0f0" color2="#000000" number="1" visible="true"/>
 </addFrame>
 <setStyle subtype="simple" type="scatter">
  <style color="#000000" color2="#000000" symbol="square" visible="true"/>
 </setStyle>
</template>

--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/
Reply | Threaded
Open this post in threaded view
|

Re: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Marta Garcia-Granero
Just an addendum:

Running the same GGRAPH command outside the macro did not give any
problems at all:

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
percwi
  MISSING=LISTWISE REPORTMISSING=NO
 /GRAPHSPEC SOURCE=INLINE TEMPLATE="C:\Temp\Forest1.sgt".
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA:   study=col(source(s),   name("study"), unit.category())
 DATA:   ciup=col(source(s),    name("ciup"))
 DATA:   cilow=col(source(s),   name("cilow"))
 DATA:   measure=col(source(s), name("measure"))
 DATA:   percwi=col(source(s),  name("percwi"))
 GUIDE:  text.title(label("Fixed Effects Model"))
 SCALE:  cat(dim(1))
 SCALE:  log(dim(2))
 COORD:  rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
END GPL.

Expected result in less than 2 seconds...

Happy weekend,
Marta García-Granero

>
> The following code (at the end of my message) is part of the process
> of writing a macro (for meta-analysis). Since the trickiest part (at
> least for me) is making GGRAPH&GPL work inside a macro (I have learned
> a bit thanks to ViAnn), I wrote a tiny macro to make sure that the
> adaptation of the GGRAPH code to the macro was correct. This piece of
> code works flawlessly in SPSS 15, but hangs miserably in SPSS 17. The
> log shows "_SLINE OFF." and then I see (status bar) "Running (in
> Spanish what I really see: "En ejecución") INLINE>...", and then SPSS
> freezes, and I can't exit the program, unless I manually run "END
> GPL.". Then I get this error message:
>
> *Advertencia
> Error de GPL: algebra(pe_SLINEOFF._SLINE292.BEGINGPL)
> Undefined com.spss.gpl.syntax.A.I: pe_SLINEOFF._SLINE292.BEGINGPL
> GPL:
>  SOURCE: s=userSource(id( "graphdataset" )) DATA: study=col(source(s),
> name( "study" ), unit.category()) DATA: ciup=col(source(s), name(
> "ciup" )) DATA: cilow=col(source(s), name( "cilow" )) DATA:
> measure=col(source(s), name( "measure" )) DATA: pe_SLINE OFF.
> _SLINE 29 2.
> BEGIN GPL
>  SOURCE: s=userSource(id(!gdataset))
>  DATA: study=col(source(s), name(!study), unit.category())
>  DATA: ciup=col(source(s), name(!ciup))
>  DATA: cilow=col(source(s), name(!cilow))
>  DATA: measure=col(source(s), name(!measure))
>  DATA: percwi=col(source(s), name(!percwi))
>  GUIDE: text.title(label(!title))
>  SCALE: cat(dim(1))
>  SCALE: log(dim(2))
>  COORD: rect(dim(1,2),transpose())
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
> El comando no puede ejecutarse.*
>

=====================
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: Problem with GGRAPH inside a macro (SPSS 17 freezes)

SPSS Support
Hi Marta,
   I replicated the results that you reported for SPSS versions 15 and 17. I've pasted a related resolution below my signature. GPL blocks aren't designed to work within macro definitions, so it was somewhat surprising that the syntax worked in SPSS 15. The resolution describes a workaround in which the Begin GPL-END GPL sequence is saved in a separate text file that is referenced from the /GRAPHSPEC subcommand inside the macro. I'm working with one of our graphics developers to build an example from your syntax.


David Matheson
SPSS Statistical Support

**************
Resolution number: 63834  Created on: Mar 17 2006  Last Reviewed on: Apr 18 2008
Resolution Status: Published - External
Problem Subject:  GPL blocks will not run from my macro or production job
Problem Description:  I am running SPSS 14 for Windows or later. I have pasted GGRAPH with BEGIN GPL/END GPL commands from the Chart Builder. I can run this syntax as is from the Syntax Editor. However, if I put this syntax into a macro, I get a message at the bottom of the screen that says "Running INLINE>" when I call the macro. From the production facility, I get a series of errors reported in my job output.

>Error # 105 on line 14. Command name: GGRAPH
>This command is not valid before a working file has been defined.
>This command not executed.

15 /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat COUNT()[rename=
16 "COUNT"] MISSING=LISTWISE REPORTMISSING=NO
17 /GRAPHSPEC SOURCE=INLINE.

>Note # 214 on line 14. Command name: GGRAPH
>Due to an error, INSERT and INCLUDE file processing has been terminated and
>the working file has been lost. You may either redefine your data or leave
>SPSS.

Why is this occurring?

Resolution Description:
BEGIN GPL/END GPL program blocks (the statements and functions within these commands) have the following rules and limitations:
.. With the SPSS Batch Facility (available only with SPSS Server), use the -i switch when
submitting command files that contain GPL blocks.
.. With the SPSS Production Facility, set the Syntax Input Mode to Interactive for jobs that contain GPL blocks.
.. GPL blocks cannot be nested within GPL blocks.
.. GPL blocks cannot be contained within DEFINE-!ENDDEFINE macro definitions.
.. GPL blocks can be contained in command syntax files run via the INSERT command, with
the default SYNTAX=INTERACTIVE setting.
.. GPL blocks cannot be contained within command syntax files run via the INCLUDE command.

It is also possible to run GPL non-interactively. Below is an example for including GGRAPH within a macro:

define mymacro().
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=vinmonth[LEVEL=ORDINAL]
COUNT()[rename="COUNT"] MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=GPLFILE("c:\test\example.gpl").
!enddefine.

where "example.gpl" is a text file with a .GPL extension containing the GPL block found between BEGIN GPL/END GPL. Please see the GRAPHSPEC subcommand for GGRAPH in the Command Syntax Reference for more information.

To escape being stuck running INLINE, run only the END GPL. command from the syntax editor.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
Sent: Friday, April 03, 2009 11:23 AM
To: [hidden email]
Subject: Re: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Just an addendum:

Running the same GGRAPH command outside the macro did not give any
problems at all:

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
percwi
  MISSING=LISTWISE REPORTMISSING=NO
 /GRAPHSPEC SOURCE=INLINE TEMPLATE="C:\Temp\Forest1.sgt".
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA:   study=col(source(s),   name("study"), unit.category())
 DATA:   ciup=col(source(s),    name("ciup"))
 DATA:   cilow=col(source(s),   name("cilow"))
 DATA:   measure=col(source(s), name("measure"))
 DATA:   percwi=col(source(s),  name("percwi"))
 GUIDE:  text.title(label("Fixed Effects Model"))
 SCALE:  cat(dim(1))
 SCALE:  log(dim(2))
 COORD:  rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
END GPL.

Expected result in less than 2 seconds...

Happy weekend,
Marta García-Granero

>
> The following code (at the end of my message) is part of the process
> of writing a macro (for meta-analysis). Since the trickiest part (at
> least for me) is making GGRAPH&GPL work inside a macro (I have learned
> a bit thanks to ViAnn), I wrote a tiny macro to make sure that the
> adaptation of the GGRAPH code to the macro was correct. This piece of
> code works flawlessly in SPSS 15, but hangs miserably in SPSS 17. The
> log shows "_SLINE OFF." and then I see (status bar) "Running (in
> Spanish what I really see: "En ejecución") INLINE>...", and then SPSS
> freezes, and I can't exit the program, unless I manually run "END
> GPL.". Then I get this error message:
>
> *Advertencia
> Error de GPL: algebra(pe_SLINEOFF._SLINE292.BEGINGPL)
> Undefined com.spss.gpl.syntax.A.I: pe_SLINEOFF._SLINE292.BEGINGPL
> GPL:
>  SOURCE: s=userSource(id( "graphdataset" )) DATA: study=col(source(s),
> name( "study" ), unit.category()) DATA: ciup=col(source(s), name(
> "ciup" )) DATA: cilow=col(source(s), name( "cilow" )) DATA:
> measure=col(source(s), name( "measure" )) DATA: pe_SLINE OFF.
> _SLINE 29 2.
> BEGIN GPL
>  SOURCE: s=userSource(id(!gdataset))
>  DATA: study=col(source(s), name(!study), unit.category())
>  DATA: ciup=col(source(s), name(!ciup))
>  DATA: cilow=col(source(s), name(!cilow))
>  DATA: measure=col(source(s), name(!measure))
>  DATA: percwi=col(source(s), name(!percwi))
>  GUIDE: text.title(label(!title))
>  SCALE: cat(dim(1))
>  SCALE: log(dim(2))
>  COORD: rect(dim(1,2),transpose())
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
> El comando no puede ejecutarse.*
>

=====================
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: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Peck, Jon
Note also that it is very easy to create the equivalent of macros by using programmability.  These could be used via a trivial program or converted into extension commands.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of SPSS Support
Sent: Friday, April 03, 2009 9:32 PM
To: [hidden email]
Subject: Re: [SPSSX-L] Problem with GGRAPH inside a macro (SPSS 17 freezes)

Hi Marta,
   I replicated the results that you reported for SPSS versions 15 and 17. I've pasted a related resolution below my signature. GPL blocks aren't designed to work within macro definitions, so it was somewhat surprising that the syntax worked in SPSS 15. The resolution describes a workaround in which the Begin GPL-END GPL sequence is saved in a separate text file that is referenced from the /GRAPHSPEC subcommand inside the macro. I'm working with one of our graphics developers to build an example from your syntax.


David Matheson
SPSS Statistical Support

**************
Resolution number: 63834  Created on: Mar 17 2006  Last Reviewed on: Apr 18 2008
Resolution Status: Published - External
Problem Subject:  GPL blocks will not run from my macro or production job
Problem Description:  I am running SPSS 14 for Windows or later. I have pasted GGRAPH with BEGIN GPL/END GPL commands from the Chart Builder. I can run this syntax as is from the Syntax Editor. However, if I put this syntax into a macro, I get a message at the bottom of the screen that says "Running INLINE>" when I call the macro. From the production facility, I get a series of errors reported in my job output.

>Error # 105 on line 14. Command name: GGRAPH
>This command is not valid before a working file has been defined.
>This command not executed.

15 /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat COUNT()[rename=
16 "COUNT"] MISSING=LISTWISE REPORTMISSING=NO
17 /GRAPHSPEC SOURCE=INLINE.

>Note # 214 on line 14. Command name: GGRAPH
>Due to an error, INSERT and INCLUDE file processing has been terminated and
>the working file has been lost. You may either redefine your data or leave
>SPSS.

Why is this occurring?

Resolution Description:
BEGIN GPL/END GPL program blocks (the statements and functions within these commands) have the following rules and limitations:
.. With the SPSS Batch Facility (available only with SPSS Server), use the -i switch when
submitting command files that contain GPL blocks.
.. With the SPSS Production Facility, set the Syntax Input Mode to Interactive for jobs that contain GPL blocks.
.. GPL blocks cannot be nested within GPL blocks.
.. GPL blocks cannot be contained within DEFINE-!ENDDEFINE macro definitions.
.. GPL blocks can be contained in command syntax files run via the INSERT command, with
the default SYNTAX=INTERACTIVE setting.
.. GPL blocks cannot be contained within command syntax files run via the INCLUDE command.

It is also possible to run GPL non-interactively. Below is an example for including GGRAPH within a macro:

define mymacro().
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=vinmonth[LEVEL=ORDINAL]
COUNT()[rename="COUNT"] MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=GPLFILE("c:\test\example.gpl").
!enddefine.

where "example.gpl" is a text file with a .GPL extension containing the GPL block found between BEGIN GPL/END GPL. Please see the GRAPHSPEC subcommand for GGRAPH in the Command Syntax Reference for more information.

To escape being stuck running INLINE, run only the END GPL. command from the syntax editor.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
Sent: Friday, April 03, 2009 11:23 AM
To: [hidden email]
Subject: Re: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Just an addendum:

Running the same GGRAPH command outside the macro did not give any
problems at all:

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
percwi
  MISSING=LISTWISE REPORTMISSING=NO
 /GRAPHSPEC SOURCE=INLINE TEMPLATE="C:\Temp\Forest1.sgt".
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA:   study=col(source(s),   name("study"), unit.category())
 DATA:   ciup=col(source(s),    name("ciup"))
 DATA:   cilow=col(source(s),   name("cilow"))
 DATA:   measure=col(source(s), name("measure"))
 DATA:   percwi=col(source(s),  name("percwi"))
 GUIDE:  text.title(label("Fixed Effects Model"))
 SCALE:  cat(dim(1))
 SCALE:  log(dim(2))
 COORD:  rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
END GPL.

Expected result in less than 2 seconds...

Happy weekend,
Marta García-Granero

>
> The following code (at the end of my message) is part of the process
> of writing a macro (for meta-analysis). Since the trickiest part (at
> least for me) is making GGRAPH&GPL work inside a macro (I have learned
> a bit thanks to ViAnn), I wrote a tiny macro to make sure that the
> adaptation of the GGRAPH code to the macro was correct. This piece of
> code works flawlessly in SPSS 15, but hangs miserably in SPSS 17. The
> log shows "_SLINE OFF." and then I see (status bar) "Running (in
> Spanish what I really see: "En ejecución") INLINE>...", and then SPSS
> freezes, and I can't exit the program, unless I manually run "END
> GPL.". Then I get this error message:
>
> *Advertencia
> Error de GPL: algebra(pe_SLINEOFF._SLINE292.BEGINGPL)
> Undefined com.spss.gpl.syntax.A.I: pe_SLINEOFF._SLINE292.BEGINGPL
> GPL:
>  SOURCE: s=userSource(id( "graphdataset" )) DATA: study=col(source(s),
> name( "study" ), unit.category()) DATA: ciup=col(source(s), name(
> "ciup" )) DATA: cilow=col(source(s), name( "cilow" )) DATA:
> measure=col(source(s), name( "measure" )) DATA: pe_SLINE OFF.
> _SLINE 29 2.
> BEGIN GPL
>  SOURCE: s=userSource(id(!gdataset))
>  DATA: study=col(source(s), name(!study), unit.category())
>  DATA: ciup=col(source(s), name(!ciup))
>  DATA: cilow=col(source(s), name(!cilow))
>  DATA: measure=col(source(s), name(!measure))
>  DATA: percwi=col(source(s), name(!percwi))
>  GUIDE: text.title(label(!title))
>  SCALE: cat(dim(1))
>  SCALE: log(dim(2))
>  COORD: rect(dim(1,2),transpose())
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
> El comando no puede ejecutarse.*
>

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

=====================
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: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Marta Garcia-Granero
In reply to this post by SPSS Support
Hi David
   I replicated the results that you reported for SPSS versions 15 and 17. I've pasted a related resolution below my signature. GPL blocks aren't designed to work within macro definitions, so it was somewhat surprising that the syntax worked in SPSS 15.
I find this a bit surprising (shocking?): something in SPSS is NOT designed to run from within a MACRO?
The resolution describes a workaround in which the Begin GPL-END GPL sequence is saved in a separate text file that is referenced from the /GRAPHSPEC subcommand inside the macro. I'm working with one of our graphics developers to build an example from your syntax.
  
Anyway, I have been giving a go at your solution, and I can not make it work. Am I doing anything wrong?

Flummoxed,
Marta

* Sample dataset *.
DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow ciup percwi(5 F8.3).
BEGIN DATA
 1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
 2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
 3 1997 Gagnon    .867 .211 .573 1.311  12.237
 4 1989 Hodnett   .502 .332 .262  .962   4.940
 5 1991 Kennell   .352 .250 .216  .575   8.694
 6 1998 Langer    .280 .162 .203  .384  20.654
 7 ---- Total     .594 .074 .514  .687 100.000
END DATA.
SORT CASES BY trial(D).
VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR' /percwi'Weights(%)'.

* macro definition *.
DEFINE MYGRAPH ().
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure percwi
  MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=GPLFILE("c:\temp\forest.gpl") TEMPLATE="C:\Temp\Forest1.sgt".
!ENDDEFINE.

"C:\Temp\forest.gpl" content:

BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA:   study=col(source(s),   name("study"), unit.category())
 DATA:   ciup=col(source(s),    name("ciup"))
 DATA:   cilow=col(source(s),   name("cilow"))
 DATA:   measure=col(source(s), name("measure"))
 DATA:   percwi=col(source(s),  name("percwi"))
 GUIDE:  text.title(label("Fixed Effects Model"))
 SCALE:  cat(dim(1))
 SCALE:  log(dim(2))
 COORD:  rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))), shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
END GPL.

* Macro call *
MYGRAPH.

This is the error message I get:

Advertencia
Error de GPL: algebra(point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.)

Expecting ( or + or * or /: point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.
GPL:
BEGIN GPL

 SOURCE: s=userSource(id("graphdataset"))

 DATA:   study=col(source(s),   name("study"), unit.category())

 DATA:   ciup=col(source(s),    name("ciup"))

 DATA:   cilow=col(source(s),   name("cilow"))

 DATA:   measure=col(source(s), name("measure"))

 DATA:   percwi=col(source(s),  name("percwi"))

 GUIDE:  text.title(label("Fixed Effects Model"))

 SCALE:  cat(dim(1))

 SCALE:  log(dim(2))

 COORD:  rect(dim(1,2),transpose())

 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))), shape(shape.line))

 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))

END GPL.
El comando no puede ejecutarse.









--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/
===================== 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: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Marta Garcia-Granero
For the records: I get the same error message if I use this approach
both in SPSS 15 & 17.

Even more flummoxed,
Marta

I wrote

> David wrote:
>> The resolution describes a workaround in which the Begin GPL-END GPL sequence is saved in a separate text file that is referenced from the /GRAPHSPEC subcommand inside the macro. I'm working with one of our graphics developers to build an example from your syntax.
>>
> I have been giving a go at your solution, and I can not make it work.
> Am I doing anything wrong?
>
>
> * Sample dataset *.
> DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow
> ciup percwi(5 F8.3).
> BEGIN DATA
>  1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
>  2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
>  3 1997 Gagnon    .867 .211 .573 1.311  12.237
>  4 1989 Hodnett   .502 .332 .262  .962   4.940
>  5 1991 Kennell   .352 .250 .216  .575   8.694
>  6 1998 Langer    .280 .162 .203  .384  20.654
>  7 ---- Total     .594 .074 .514  .687 100.000
> END DATA.
> SORT CASES BY trial(D).
> VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR'
> /percwi'Weights(%)'.
>
> * macro definition *.
> DEFINE MYGRAPH ().
> GGRAPH
>   /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
> percwi
>   MISSING=LISTWISE REPORTMISSING=NO
> /GRAPHSPEC SOURCE=GPLFILE("c:\temp\forest.gpl")
> TEMPLATE="C:\Temp\Forest1.sgt".
> !ENDDEFINE.
>
> "C:\Temp\forest.gpl" content:
>
> BEGIN GPL
>  SOURCE: s=userSource(id("graphdataset"))
>  DATA:   study=col(source(s),   name("study"), unit.category())
>  DATA:   ciup=col(source(s),    name("ciup"))
>  DATA:   cilow=col(source(s),   name("cilow"))
>  DATA:   measure=col(source(s), name("measure"))
>  DATA:   percwi=col(source(s),  name("percwi"))
>  GUIDE:  text.title(label("Fixed Effects Model"))
>  SCALE:  cat(dim(1))
>  SCALE:  log(dim(2))
>  COORD:  rect(dim(1,2),transpose())
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
> END GPL.
>
> * Macro call *
> MYGRAPH.
>
> This is the error message I get:
>
> *Advertencia
> Error de GPL:
> algebra(point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.)
>
> Expecting ( or + or * or /:
> point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.
> GPL:
> BEGIN GPL
>
>  SOURCE: s=userSource(id("graphdataset"))
>
>  DATA:   study=col(source(s),   name("study"), unit.category())
>
>  DATA:   ciup=col(source(s),    name("ciup"))
>
>  DATA:   cilow=col(source(s),   name("cilow"))
>
>  DATA:   measure=col(source(s), name("measure"))
>
>  DATA:   percwi=col(source(s),  name("percwi"))
>
>  GUIDE:  text.title(label("Fixed Effects Model"))
>
>  SCALE:  cat(dim(1))
>
>  SCALE:  log(dim(2))
>
>  COORD:  rect(dim(1,2),transpose())
>
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
>
> END GPL.
> El comando no puede ejecutarse.*
>
--

For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

=====================
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: Problem with GGRAPH inside a macro (SPSS 17 freezes)

SPSS Support
Hi Marta,

Here is the information that I received from the graphics developer.

There are two problems in your original syntax from your post on Friday:

1.      The Begin Data/End Data commands create a new dataset, but do not name or activate that data set.  Somehow when used inside of a macro, GGraph gets confused and looks at the empty dataset.  This is why you get the "can not find variable study" message.  It's not clear yet whether this is a bug or not.  You can get around it by activating the dataset.
2.      If you activate the dataset, it hangs, waiting for an "End GPL." command.  This was introduced in 17.0 when they added the feature to report errors to the syntax window.  It was implemented by adding a hidden syntax command after every command line.  This is getting mixed up with the GPL.  A new bug been filed for this.

As for the GPLFILE option in the resolution workaround, you can get this to work if you do the following:

1.      Remove the "Begin GPL" and "End GPL." lines from the file.  The GPL file must contain only GPL.  These lines are used for INLINE GPL only.
2.      Macros do not apply to the GPLFILE option.  Change your variable names/text to use the "real" gpl, and it will work.

The developer noted that GPL commands can sometimes work within a macro if the GPL block is very compact, but it is not a sure bet.

I've pasted revised versions of your syntax below. This syntax reads the inline data and names the dataset, defines the macro and makes the macro call. There are 2 versions, both of which I've run successfully in versions 15 and 17. The first version includes the path to the gpl block file (exampleMG.gpl) as an argument to the SOURCE=GPLFILE() keywords in the /GRAPHSPEC subcommand of GGRAPH. The second version defines that path as the macro variable !source in a !LET command and then references !source in the /GRAPHSPEC subcommand. Following these syntax blocks, I've pasted the content of the GPLFILE that is referenced in the macro definition. In this example, that file (exampleMG.gpl) is stored in c:\temp, like the template file Forest1.sgt.

I hope this helps.
David Matheson
SPSS Statistical Support

*******************************.
* Version 1 .
* Sample dataset *.
DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow ciup percwi(5 F8.3).
BEGIN DATA
 1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
 2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
 3 1997 Gagnon    .867 .211 .573 1.311  12.237
 4 1989 Hodnett   .502 .332 .262  .962   4.940
 5 1991 Kennell   .352 .250 .216  .575   8.694
 6 1998 Langer    .280 .162 .203  .384  20.654
 7 ---- Total     .594 .074 .514  .687 100.000
END DATA.
SORT CASES BY trial(D).
VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR' /percwi'Weights(%)'.
dataset name graphdataset .

* Macro definition *.
DEFINE MYGRAPH ().
!LET !title=!CONCAT('"','Fixed Effects Model','"').
!LET !template=!CONCAT('"','C:\Temp\Forest1.sgt','"').
!LET !gdataset=!CONCAT('"','graphdataset','"').
!LET !study=!CONCAT('"','study','"').
!LET !ciup=!CONCAT('"','ciup','"').
!LET !cilow=!CONCAT('"','cilow','"').
!LET !measure=!CONCAT('"','measure','"').
!LET !percwi=!CONCAT('"','percwi','"').

GGRAPH
  /GRAPHDATASET NAME=!gdataset VARIABLES=study ciup cilow measure percwi
  MISSING=LISTWISE REPORTMISSING=NO
 /GRAPHSPEC SOURCE=GPLFILE("c:\temp\exampleMG.gpl") TEMPLATE=!template.

!ENDDEFINE.

dataset activate graphdataset .
* Macro call *.
MYGRAPH.

*********************************.
* Version 2 .
* Sample dataset *.
DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow ciup percwi(5 F8.3).
BEGIN DATA
 1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
 2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
 3 1997 Gagnon    .867 .211 .573 1.311  12.237
 4 1989 Hodnett   .502 .332 .262  .962   4.940
 5 1991 Kennell   .352 .250 .216  .575   8.694
 6 1998 Langer    .280 .162 .203  .384  20.654
 7 ---- Total     .594 .074 .514  .687 100.000
END DATA.
SORT CASES BY trial(D).
VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR' /percwi'Weights(%)'.
dataset name graphdataset .

* Macro definition *.
DEFINE MYGRAPH ().
!LET !title=!CONCAT('"','Fixed Effects Model','"').
!LET !template=!CONCAT('"','C:\Temp\Forest1.sgt','"').
!LET !gdataset=!CONCAT('"','graphdataset','"').
!LET !study=!CONCAT('"','study','"').
!LET !ciup=!CONCAT('"','ciup','"').
!LET !cilow=!CONCAT('"','cilow','"').
!LET !measure=!CONCAT('"','measure','"').
!LET !source=!CONCAT('"','c:\temp\exampleMG.gpl','"').
!LET !percwi=!CONCAT('"','percwi','"').

GGRAPH
  /GRAPHDATASET NAME=!gdataset VARIABLES=study ciup cilow measure percwi
  MISSING=LISTWISE REPORTMISSING=NO
 /GRAPHSPEC SOURCE=GPLFILE(!source) TEMPLATE=!template.

!ENDDEFINE.

dataset activate graphdataset .
* Macro call *.
MYGRAPH.

********************************.

* Contents of exampleMG.gpl .


SOURCE: s=userSource(id("graphdataset"))
 DATA:   study=col(source(s),   name("study"), unit.category())
 DATA:   ciup=col(source(s),    name("ciup"))
 DATA:   cilow=col(source(s),   name("cilow"))
 DATA:   measure=col(source(s), name("measure"))
 DATA:   percwi=col(source(s),  name("percwi"))
 GUIDE:  text.title(label("Fixed Effects Model"))
 SCALE:  cat(dim(1))
 SCALE:  log(dim(2))
 COORD:  rect(dim(1,2),transpose())
 ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))), shape(shape.line))
 ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
Sent: Monday, April 06, 2009 4:51 AM
To: [hidden email]
Subject: Re: Problem with GGRAPH inside a macro (SPSS 17 freezes)

For the records: I get the same error message if I use this approach
both in SPSS 15 & 17.

Even more flummoxed,
Marta

I wrote

> David wrote:
>> The resolution describes a workaround in which the Begin GPL-END GPL sequence is saved in a separate text file that is referenced from the /GRAPHSPEC subcommand inside the macro. I'm working with one of our graphics developers to build an example from your syntax.
>>
> I have been giving a go at your solution, and I can not make it work.
> Am I doing anything wrong?
>
>
> * Sample dataset *.
> DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow
> ciup percwi(5 F8.3).
> BEGIN DATA
>  1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
>  2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
>  3 1997 Gagnon    .867 .211 .573 1.311  12.237
>  4 1989 Hodnett   .502 .332 .262  .962   4.940
>  5 1991 Kennell   .352 .250 .216  .575   8.694
>  6 1998 Langer    .280 .162 .203  .384  20.654
>  7 ---- Total     .594 .074 .514  .687 100.000
> END DATA.
> SORT CASES BY trial(D).
> VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR'
> /percwi'Weights(%)'.
>
> * macro definition *.
> DEFINE MYGRAPH ().
> GGRAPH
>   /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
> percwi
>   MISSING=LISTWISE REPORTMISSING=NO
> /GRAPHSPEC SOURCE=GPLFILE("c:\temp\forest.gpl")
> TEMPLATE="C:\Temp\Forest1.sgt".
> !ENDDEFINE.
>
> "C:\Temp\forest.gpl" content:
>
> BEGIN GPL
>  SOURCE: s=userSource(id("graphdataset"))
>  DATA:   study=col(source(s),   name("study"), unit.category())
>  DATA:   ciup=col(source(s),    name("ciup"))
>  DATA:   cilow=col(source(s),   name("cilow"))
>  DATA:   measure=col(source(s), name("measure"))
>  DATA:   percwi=col(source(s),  name("percwi"))
>  GUIDE:  text.title(label("Fixed Effects Model"))
>  SCALE:  cat(dim(1))
>  SCALE:  log(dim(2))
>  COORD:  rect(dim(1,2),transpose())
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
> END GPL.
>
> * Macro call *
> MYGRAPH.
>
> This is the error message I get:
>
> *Advertencia
> Error de GPL:
> algebra(point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.)
>
> Expecting ( or + or * or /:
> point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.
> GPL:
> BEGIN GPL
>
>  SOURCE: s=userSource(id("graphdataset"))
>
>  DATA:   study=col(source(s),   name("study"), unit.category())
>
>  DATA:   ciup=col(source(s),    name("ciup"))
>
>  DATA:   cilow=col(source(s),   name("cilow"))
>
>  DATA:   measure=col(source(s), name("measure"))
>
>  DATA:   percwi=col(source(s),  name("percwi"))
>
>  GUIDE:  text.title(label("Fixed Effects Model"))
>
>  SCALE:  cat(dim(1))
>
>  SCALE:  log(dim(2))
>
>  COORD:  rect(dim(1,2),transpose())
>
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
> shape(shape.line))
>
>  ELEMENT: point(position(study*measure), shape(shape.square),
> size(percwi))
>
> END GPL.
> El comando no puede ejecutarse.*
>
--

For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

=====================
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: Problem with GGRAPH inside a macro (SPSS 17 freezes)

Marta Garcia-Granero
SPSS Support wrote:

> Here is the information that I received from the graphics developer.
>
> There are two problems in your original syntax from your post on Friday:
>
> 1.    The Begin Data/End Data commands create a new dataset, but do not name or activate that data set.  Somehow when used inside of a macro, GGraph gets confused and looks at the empty dataset.  This is why you get the "can not find variable study" message.  It's not clear yet whether this is a bug or not.  You can get around it by activating the dataset.
> 2.    If you activate the dataset, it hangs, waiting for an "End GPL." command.  This was introduced in 17.0 when they added the feature to report errors to the syntax window.  It was implemented by adding a hidden syntax command after every command line.  This is getting mixed up with the GPL.  A new bug been filed for this.
>
> As for the GPLFILE option in the resolution workaround, you can get this to work if you do the following:
>
> 1.    Remove the "Begin GPL" and "End GPL." lines from the file.  The GPL file must contain only GPL.  These lines are used for INLINE GPL only.
>
That makes sense, I should have thought of that!
> 2.    Macros do not apply to the GPLFILE option.  Change your variable names/text to use the "real" gpl, and it will work.
>
I had already figured that out during my testings.

Following your instructions, I finally got something (see below) that
worked both with SPSS15 & 17 (my final macro will look very complicated,
since the "forest.gpl" file will have to be written dynamically using
WRITE OUTFILE, but that's a piece of cake now that this GPL problem is
over).

Thanks a lot, I consider the problem closed now.
Marta
-----------------------

a) MACRO definition:

DEFINE MYGRAPH ().
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
percwi
  MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=GPLFILE("c:\temp\forest.gpl")
TEMPLATE="C:\Temp\Forest1.sgt".
!ENDDEFINE.

b) Sample dataset & MACRO call:

DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow
ciup percwi(5 F8.3).
BEGIN DATA
 1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
 2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
 3 1997 Gagnon    .867 .211 .573 1.311  12.237
 4 1989 Hodnett   .502 .332 .262  .962   4.940
 5 1991 Kennell   .352 .250 .216  .575   8.694
 6 1998 Langer    .280 .162 .203  .384  20.654
 7 ---- Total     .594 .074 .514  .687 100.000
END DATA.
* Sorting the fle has the desired effect only in SPSS 15 *.
SORT CASES BY trial(D).
VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR'
/percwi'Weights(%)'.
DATASET NAME graphdataset.

MYGRAPH.

c) Contents of "C:\Temp\Forest.gpl" file:

SOURCE: s=userSource(id("graphdataset"))
DATA:   study=col(source(s),   name("study"), unit.category())
DATA:   ciup=col(source(s),    name("ciup"))
DATA:   cilow=col(source(s),   name("cilow"))
DATA:   measure=col(source(s), name("measure"))
DATA:   percwi=col(source(s),  name("percwi"))
GUIDE:  text.title(label("Fixed Effects Model"))
SCALE:  cat(dim(1))
SCALE:  log(dim(2))
COORD:  rect(dim(1,2),transpose())
ELEMENT:
interval(position(region.spread.range(study*(cilow+ciup))),shape(shape.line))

ELEMENT: point(position(study*measure),shape(shape.square),size(percwi))

d) Contents of "C:\Temp\Forest1.sgt" file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<template SPSS-Version="2.2" selectPath="87 2 30 97 98 12 13 900 "
xmlns="http://xml.spss.com/spss/visualization"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xml.spss.com/spss/visualization
http://xml.spss.com/spss/visualization/vizml-template-3.0.xsd">
 <setAxisStyle categorical="true" role="x">
  <label>Study name</label>
  <style color="#000000" stroke-width="0.5pt" visible="true"/>
 </setAxisStyle>
 <setAxisStyle categorical="false" role="y">
  <label> Favours treatment                 Favours Control</label>
  <style color="#000000" stroke-width="0.5pt" visible="true"/>
 </setAxisStyle>
 <addFrame count="1" type="visualization">
  <location bottom="556px" left="0px" right="433px" top="0px"/>
  <style color="#ffffff" color2="transparent" number="0" visible="true"/>
  <style font-family="SansSerif" font-size="8pt" number="1" pattern="0"
stroke-linecap="butt" text-fit="true" visible="true"/>
 </addFrame>
 <setErrorBarOptions>
  <style color="#000000" color2="#000000" depth="75%" pattern="0"
stroke-width="0.25pt" symbol="line" visible="true" width="0.25pt"/>
 </setErrorBarOptions>
 <addReferenceLine styleOnly="false" y="1.0" ycategorical="false">
  <style stroke-dasharray="3px,2px" visible="true" width="0.5pt"/>
 </addReferenceLine>
 <addFrame count="1" styleOnly="true" type="legend">
  <style color="transparent" color2="transparent" visible="false"/>
  <style color="transparent" color2="transparent" number="0"
visible="false"/>
 </addFrame>
 <addFrame count="1" styleOnly="true" type="graph">
  <style color="transparent" color2="transparent" visible="true"/>
  <style color="#f0f0f0" color2="#000000" number="1" visible="true"/>
 </addFrame>
 <setStyle subtype="simple" type="scatter">
  <style color="#000000" color2="#000000" symbol="square" visible="true"/>
 </setStyle>
</template>


> The developer noted that GPL commands can sometimes work within a macro if the GPL block is very compact, but it is not a sure bet.
>
> I've pasted revised versions of your syntax below. This syntax reads the inline data and names the dataset, defines the macro and makes the macro call. There are 2 versions, both of which I've run successfully in versions 15 and 17. The first version includes the path to the gpl block file (exampleMG.gpl) as an argument to the SOURCE=GPLFILE() keywords in the /GRAPHSPEC subcommand of GGRAPH. The second version defines that path as the macro variable !source in a !LET command and then references !source in the /GRAPHSPEC subcommand. Following these syntax blocks, I've pasted the content of the GPLFILE that is referenced in the macro definition. In this example, that file (exampleMG.gpl) is stored in c:\temp, like the template file Forest1.sgt.
>
> I hope this helps.
> David Matheson
> SPSS Statistical Support
>
> *******************************.
> * Version 1 .
> * Sample dataset *.
> DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow ciup percwi(5 F8.3).
> BEGIN DATA
>  1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
>  2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
>  3 1997 Gagnon    .867 .211 .573 1.311  12.237
>  4 1989 Hodnett   .502 .332 .262  .962   4.940
>  5 1991 Kennell   .352 .250 .216  .575   8.694
>  6 1998 Langer    .280 .162 .203  .384  20.654
>  7 ---- Total     .594 .074 .514  .687 100.000
> END DATA.
> SORT CASES BY trial(D).
> VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR' /percwi'Weights(%)'.
> dataset name graphdataset .
>
> * Macro definition *.
> DEFINE MYGRAPH ().
> !LET !title=!CONCAT('"','Fixed Effects Model','"').
> !LET !template=!CONCAT('"','C:\Temp\Forest1.sgt','"').
> !LET !gdataset=!CONCAT('"','graphdataset','"').
> !LET !study=!CONCAT('"','study','"').
> !LET !ciup=!CONCAT('"','ciup','"').
> !LET !cilow=!CONCAT('"','cilow','"').
> !LET !measure=!CONCAT('"','measure','"').
> !LET !percwi=!CONCAT('"','percwi','"').
>
> GGRAPH
>   /GRAPHDATASET NAME=!gdataset VARIABLES=study ciup cilow measure percwi
>   MISSING=LISTWISE REPORTMISSING=NO
>  /GRAPHSPEC SOURCE=GPLFILE("c:\temp\exampleMG.gpl") TEMPLATE=!template.
>
> !ENDDEFINE.
>
> dataset activate graphdataset .
> * Macro call *.
> MYGRAPH.
>
> *********************************.
> * Version 2 .
> * Sample dataset *.
> DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow ciup percwi(5 F8.3).
> BEGIN DATA
>  1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
>  2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
>  3 1997 Gagnon    .867 .211 .573 1.311  12.237
>  4 1989 Hodnett   .502 .332 .262  .962   4.940
>  5 1991 Kennell   .352 .250 .216  .575   8.694
>  6 1998 Langer    .280 .162 .203  .384  20.654
>  7 ---- Total     .594 .074 .514  .687 100.000
> END DATA.
> SORT CASES BY trial(D).
> VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR' /percwi'Weights(%)'.
> dataset name graphdataset .
>
> * Macro definition *.
> DEFINE MYGRAPH ().
> !LET !title=!CONCAT('"','Fixed Effects Model','"').
> !LET !template=!CONCAT('"','C:\Temp\Forest1.sgt','"').
> !LET !gdataset=!CONCAT('"','graphdataset','"').
> !LET !study=!CONCAT('"','study','"').
> !LET !ciup=!CONCAT('"','ciup','"').
> !LET !cilow=!CONCAT('"','cilow','"').
> !LET !measure=!CONCAT('"','measure','"').
> !LET !source=!CONCAT('"','c:\temp\exampleMG.gpl','"').
> !LET !percwi=!CONCAT('"','percwi','"').
>
> GGRAPH
>   /GRAPHDATASET NAME=!gdataset VARIABLES=study ciup cilow measure percwi
>   MISSING=LISTWISE REPORTMISSING=NO
>  /GRAPHSPEC SOURCE=GPLFILE(!source) TEMPLATE=!template.
>
> !ENDDEFINE.
>
> dataset activate graphdataset .
> * Macro call *.
> MYGRAPH.
>
> ********************************.
>
> * Contents of exampleMG.gpl .
>
>
> SOURCE: s=userSource(id("graphdataset"))
>  DATA:   study=col(source(s),   name("study"), unit.category())
>  DATA:   ciup=col(source(s),    name("ciup"))
>  DATA:   cilow=col(source(s),   name("cilow"))
>  DATA:   measure=col(source(s), name("measure"))
>  DATA:   percwi=col(source(s),  name("percwi"))
>  GUIDE:  text.title(label("Fixed Effects Model"))
>  SCALE:  cat(dim(1))
>  SCALE:  log(dim(2))
>  COORD:  rect(dim(1,2),transpose())
>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))), shape(shape.line))
>  ELEMENT: point(position(study*measure), shape(shape.square), size(percwi))
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
> Sent: Monday, April 06, 2009 4:51 AM
> To: [hidden email]
> Subject: Re: Problem with GGRAPH inside a macro (SPSS 17 freezes)
>
> For the records: I get the same error message if I use this approach
> both in SPSS 15 & 17.
>
> Even more flummoxed,
> Marta
>
> I wrote
>
>> David wrote:
>>
>>> The resolution describes a workaround in which the Begin GPL-END GPL sequence is saved in a separate text file that is referenced from the /GRAPHSPEC subcommand inside the macro. I'm working with one of our graphics developers to build an example from your syntax.
>>>
>>>
>> I have been giving a go at your solution, and I can not make it work.
>> Am I doing anything wrong?
>>
>>
>> * Sample dataset *.
>> DATA LIST LIST/ trial(F4) year(A5) study(A10) measure semeasur cilow
>> ciup percwi(5 F8.3).
>> BEGIN DATA
>>  1 1992 Bréart-Fr .785 .248 .483 1.276   8.878
>>  2 1992 Bréart-Bg .811 .111 .653 1.007  44.598
>>  3 1997 Gagnon    .867 .211 .573 1.311  12.237
>>  4 1989 Hodnett   .502 .332 .262  .962   4.940
>>  5 1991 Kennell   .352 .250 .216  .575   8.694
>>  6 1998 Langer    .280 .162 .203  .384  20.654
>>  7 ---- Total     .594 .074 .514  .687 100.000
>> END DATA.
>> SORT CASES BY trial(D).
>> VAR LABEL cilow 'Lower 95%CI' /ciup 'Upper 95%CI' /measure 'OR'
>> /percwi'Weights(%)'.
>>
>> * macro definition *.
>> DEFINE MYGRAPH ().
>> GGRAPH
>>   /GRAPHDATASET NAME="graphdataset" VARIABLES=study ciup cilow measure
>> percwi
>>   MISSING=LISTWISE REPORTMISSING=NO
>> /GRAPHSPEC SOURCE=GPLFILE("c:\temp\forest.gpl")
>> TEMPLATE="C:\Temp\Forest1.sgt".
>> !ENDDEFINE.
>>
>> "C:\Temp\forest.gpl" content:
>>
>> BEGIN GPL
>>  SOURCE: s=userSource(id("graphdataset"))
>>  DATA:   study=col(source(s),   name("study"), unit.category())
>>  DATA:   ciup=col(source(s),    name("ciup"))
>>  DATA:   cilow=col(source(s),   name("cilow"))
>>  DATA:   measure=col(source(s), name("measure"))
>>  DATA:   percwi=col(source(s),  name("percwi"))
>>  GUIDE:  text.title(label("Fixed Effects Model"))
>>  SCALE:  cat(dim(1))
>>  SCALE:  log(dim(2))
>>  COORD:  rect(dim(1,2),transpose())
>>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
>> shape(shape.line))
>>  ELEMENT: point(position(study*measure), shape(shape.square),
>> size(percwi))
>> END GPL.
>>
>> * Macro call *
>> MYGRAPH.
>>
>> This is the error message I get:
>>
>> *Advertencia
>> Error de GPL:
>> algebra(point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.)
>>
>> Expecting ( or + or * or /:
>> point(position(study*measure),shape(shape.square),size(percwi))ENDGPL.
>> GPL:
>> BEGIN GPL
>>
>>  SOURCE: s=userSource(id("graphdataset"))
>>
>>  DATA:   study=col(source(s),   name("study"), unit.category())
>>
>>  DATA:   ciup=col(source(s),    name("ciup"))
>>
>>  DATA:   cilow=col(source(s),   name("cilow"))
>>
>>  DATA:   measure=col(source(s), name("measure"))
>>
>>  DATA:   percwi=col(source(s),  name("percwi"))
>>
>>  GUIDE:  text.title(label("Fixed Effects Model"))
>>
>>  SCALE:  cat(dim(1))
>>
>>  SCALE:  log(dim(2))
>>
>>  COORD:  rect(dim(1,2),transpose())
>>
>>  ELEMENT: interval(position(region.spread.range(study*(cilow+ciup))),
>> shape(shape.line))
>>
>>  ELEMENT: point(position(study*measure), shape(shape.square),
>> size(percwi))
>>
>> END GPL.
>> El comando no puede ejecutarse.*
>>
>>
> --
>
> For miscellaneous statistical stuff, visit:
> http://gjyp.nl/marta/
>
> =====================
> 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
>
>


--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

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