creating multiple charts with chart builder

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

creating multiple charts with chart builder

LUCINDA M TEAR
Hello,

I am just venturing into Chart Builder instead of using Interactive Charts because I want to be able to use the "logarithmic" axis transformation on the scale axis when I am creating a set of multiple boxplots.

I have read the syntax help, but I am not sure how to create a "macro" that will allow me create multiple boxplots, one for each of 11 variables, such that each boxplot uses the variable LABEL name as the axis label and does NOT include labels for outliers.

I have the following syntax - I have tried to use the "NAME=" function so that I would have to change only the variable name after the VARIABLES = command, but this doesn't work to change the axis label and I'm not sure how to get it to read a list of variable names so that several boxplots are created.  

Any help would be appreciated!  Thank you,  Lucinda Tear

* Chart Builder.

GGRAPH

/GRAPHDATASET NAME="graphdataset" VARIABLES=chem1 [NAME="chem"] MISSING=VARIABLEWISE

REPORTMISSING=NO

/GRAPHSPEC SOURCE=INLINE

TEMPLATE=["C:\Program Files\SPSS\Looks\air_boxes.sgt"].

BEGIN GPL

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

DATA: chem=col(source(s), name("chem")) #I replaced chem1 with "chem" here to try to make it more generic

DATA: id=col(source(s), name("$CASENUM"), unit.category())  

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

GUIDE: axis(dim(1), label("WHAT CAN I PUT HERE SO THAT THE AXIS LABEL NAME CHANGES WITH EACH VARIABLE"))

SCALE: log(dim(1), base(10))

ELEMENT: schema(position(bin.quantile.letter(chem)), label(id)) #I replaced chem1 with "chem" here to try to make it more generic

END GPL.

====================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: creating multiple charts with chart builder

ViAnn Beadle
When Chart Builder creates syntax, it knows what the variable label for the
selected variable is and uses that when generating the GUIDE statement.
Unlike Chart Builder, macros are simple substitutions of strings and have no
direct knowledge of dictionary information. I have seen some solutions in
which SPSS itself is coaxed into writing a macro with dictionary information
within it but I haven't a clue as to how to go about this.

It's fairly easy to use python to retrieve a variable label from a variable
name and place that in the middle of the label function on the GUIDE
statement. However, I don't think that you can embed a python program inside
of a macro used to generate 11 separate instances of the GGRAPH command. You
might be able to use a python program which does the looping through the
names and I'm sure that python fans on the list can come up with something
that works.

Tell us more about your sets of 11 variables. Do they have some common name
part to them such as chem1 to chem11?

On a simpler note, to suppress the outlier labels, omit the label(id)
function from your ELEMENT statement and drop the DATA statement defining
the id variable.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
LUCINDA M TEAR
Sent: Wednesday, August 13, 2008 5:29 PM
To: [hidden email]
Subject: creating multiple charts with chart builder

Hello,

I am just venturing into Chart Builder instead of using Interactive Charts
because I want to be able to use the "logarithmic" axis transformation on
the scale axis when I am creating a set of multiple boxplots.

I have read the syntax help, but I am not sure how to create a "macro" that
will allow me create multiple boxplots, one for each of 11 variables, such
that each boxplot uses the variable LABEL name as the axis label and does
NOT include labels for outliers.

I have the following syntax - I have tried to use the "NAME=" function so
that I would have to change only the variable name after the VARIABLES =
command, but this doesn't work to change the axis label and I'm not sure how
to get it to read a list of variable names so that several boxplots are
created.

Any help would be appreciated!  Thank you,  Lucinda Tear

* Chart Builder.

GGRAPH

/GRAPHDATASET NAME="graphdataset" VARIABLES=chem1 [NAME="chem"]
MISSING=VARIABLEWISE

REPORTMISSING=NO

/GRAPHSPEC SOURCE=INLINE

TEMPLATE=["C:\Program Files\SPSS\Looks\air_boxes.sgt"].

BEGIN GPL

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

DATA: chem=col(source(s), name("chem")) #I replaced chem1 with "chem" here
to try to make it more generic

DATA: id=col(source(s), name("$CASENUM"), unit.category())

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

GUIDE: axis(dim(1), label("WHAT CAN I PUT HERE SO THAT THE AXIS LABEL NAME
CHANGES WITH EACH VARIABLE"))

SCALE: log(dim(1), base(10))

ELEMENT: schema(position(bin.quantile.letter(chem)), label(id)) #I replaced
chem1 with "chem" here to try to make it more generic

END GPL.

=======
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: creating multiple charts with chart builder

LUCINDA M TEAR
Thank you, ViAnn for your help re: outlier labels.  My variable names (actually, I have 19 - more than I thought!) do have common names:  chem1 to chem19.  I tried using the !concat() function and creating a (define - !enddefine) macro, but that didn't work.  The syntax guide for ggraph indicates that name can be used to create multiple graphs with the same syntax, but doesn't provide any examples of that....

Thanks again!

Lucinda


----- Original Message -----
  From: ViAnn Beadle<mailto:[hidden email]>
  To: [hidden email]<mailto:[hidden email]>
  Sent: Wednesday, August 13, 2008 4:57 PM
  Subject: Re: creating multiple charts with chart builder


  When Chart Builder creates syntax, it knows what the variable label for the
  selected variable is and uses that when generating the GUIDE statement.
  Unlike Chart Builder, macros are simple substitutions of strings and have no
  direct knowledge of dictionary information. I have seen some solutions in
  which SPSS itself is coaxed into writing a macro with dictionary information
  within it but I haven't a clue as to how to go about this.

  It's fairly easy to use python to retrieve a variable label from a variable
  name and place that in the middle of the label function on the GUIDE
  statement. However, I don't think that you can embed a python program inside
  of a macro used to generate 11 separate instances of the GGRAPH command. You
  might be able to use a python program which does the looping through the
  names and I'm sure that python fans on the list can come up with something
  that works.

  Tell us more about your sets of 11 variables. Do they have some common name
  part to them such as chem1 to chem11?

  On a simpler note, to suppress the outlier labels, omit the label(id)
  function from your ELEMENT statement and drop the DATA statement defining
  the id variable.

  -----Original Message-----
  From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
  LUCINDA M TEAR
  Sent: Wednesday, August 13, 2008 5:29 PM
  To: [hidden email]<mailto:[hidden email]>
  Subject: creating multiple charts with chart builder

  Hello,

  I am just venturing into Chart Builder instead of using Interactive Charts
  because I want to be able to use the "logarithmic" axis transformation on
  the scale axis when I am creating a set of multiple boxplots.

  I have read the syntax help, but I am not sure how to create a "macro" that
  will allow me create multiple boxplots, one for each of 11 variables, such
  that each boxplot uses the variable LABEL name as the axis label and does
  NOT include labels for outliers.

  I have the following syntax - I have tried to use the "NAME=" function so
  that I would have to change only the variable name after the VARIABLES =
  command, but this doesn't work to change the axis label and I'm not sure how
  to get it to read a list of variable names so that several boxplots are
  created.

  Any help would be appreciated!  Thank you,  Lucinda Tear

  * Chart Builder.

  GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=chem1 [NAME="chem"]
  MISSING=VARIABLEWISE

  REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE

  TEMPLATE=["C:\Program Files\SPSS\Looks\air_boxes.sgt"].

  BEGIN GPL

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

  DATA: chem=col(source(s), name("chem")) #I replaced chem1 with "chem" here
  to try to make it more generic

  DATA: id=col(source(s), name("$CASENUM"), unit.category())

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

  GUIDE: axis(dim(1), label("WHAT CAN I PUT HERE SO THAT THE AXIS LABEL NAME
  CHANGES WITH EACH VARIABLE"))

  SCALE: log(dim(1), base(10))

  ELEMENT: schema(position(bin.quantile.letter(chem)), label(id)) #I replaced
  chem1 with "chem" here to try to make it more generic

  END GPL.

  =======
  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]<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
Reply | Threaded
Open this post in threaded view
|

Re: creating multiple charts with chart builder

Peck, Jon
Python string substitution works much better than macro with GPL.  You can find an example of a chart generated this way in the paretochart.py module downloadable from SPSS Developer Central (www.spss.com/devcentral) or in the pls.py module installed when you install the Partial Least Squares addon for SPSS 16.  But these do require some Python knowledge.

As a general approach, I would define a Python function whose arguments are the parameters you want to substitute in GGRAPH/GPL, make a template of the syntax you want, and pass it the parameters.  If this is all Greek to you, though, this might not be the shortest route to a solution.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of LUCINDA M TEAR
Sent: Wednesday, August 13, 2008 6:21 PM
To: [hidden email]
Subject: Re: [SPSSX-L] creating multiple charts with chart builder

Thank you, ViAnn for your help re: outlier labels.  My variable names (actually, I have 19 - more than I thought!) do have common names:  chem1 to chem19.  I tried using the !concat() function and creating a (define - !enddefine) macro, but that didn't work.  The syntax guide for ggraph indicates that name can be used to create multiple graphs with the same syntax, but doesn't provide any examples of that....

Thanks again!

Lucinda


----- Original Message -----
  From: ViAnn Beadle<mailto:[hidden email]>
  To: [hidden email]<mailto:[hidden email]>
  Sent: Wednesday, August 13, 2008 4:57 PM
  Subject: Re: creating multiple charts with chart builder


  When Chart Builder creates syntax, it knows what the variable label for the
  selected variable is and uses that when generating the GUIDE statement.
  Unlike Chart Builder, macros are simple substitutions of strings and have no
  direct knowledge of dictionary information. I have seen some solutions in
  which SPSS itself is coaxed into writing a macro with dictionary information
  within it but I haven't a clue as to how to go about this.

  It's fairly easy to use python to retrieve a variable label from a variable
  name and place that in the middle of the label function on the GUIDE
  statement. However, I don't think that you can embed a python program inside
  of a macro used to generate 11 separate instances of the GGRAPH command. You
  might be able to use a python program which does the looping through the
  names and I'm sure that python fans on the list can come up with something
  that works.

  Tell us more about your sets of 11 variables. Do they have some common name
  part to them such as chem1 to chem11?

  On a simpler note, to suppress the outlier labels, omit the label(id)
  function from your ELEMENT statement and drop the DATA statement defining
  the id variable.

  -----Original Message-----
  From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
  LUCINDA M TEAR
  Sent: Wednesday, August 13, 2008 5:29 PM
  To: [hidden email]<mailto:[hidden email]>
  Subject: creating multiple charts with chart builder

  Hello,

  I am just venturing into Chart Builder instead of using Interactive Charts
  because I want to be able to use the "logarithmic" axis transformation on
  the scale axis when I am creating a set of multiple boxplots.

  I have read the syntax help, but I am not sure how to create a "macro" that
  will allow me create multiple boxplots, one for each of 11 variables, such
  that each boxplot uses the variable LABEL name as the axis label and does
  NOT include labels for outliers.

  I have the following syntax - I have tried to use the "NAME=" function so
  that I would have to change only the variable name after the VARIABLES =
  command, but this doesn't work to change the axis label and I'm not sure how
  to get it to read a list of variable names so that several boxplots are
  created.

  Any help would be appreciated!  Thank you,  Lucinda Tear

  * Chart Builder.

  GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=chem1 [NAME="chem"]
  MISSING=VARIABLEWISE

  REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE

  TEMPLATE=["C:\Program Files\SPSS\Looks\air_boxes.sgt"].

  BEGIN GPL

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

  DATA: chem=col(source(s), name("chem")) #I replaced chem1 with "chem" here
  to try to make it more generic

  DATA: id=col(source(s), name("$CASENUM"), unit.category())

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

  GUIDE: axis(dim(1), label("WHAT CAN I PUT HERE SO THAT THE AXIS LABEL NAME
  CHANGES WITH EACH VARIABLE"))

  SCALE: log(dim(1), base(10))

  ELEMENT: schema(position(bin.quantile.letter(chem)), label(id)) #I replaced
  chem1 with "chem" here to try to make it more generic

  END GPL.

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

=====================
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: creating multiple charts with chart builder

LUCINDA M TEAR
Thank you, Jon!  The general terms are not Greek, but I don't know Python, so I'll see if I can decipher the link you sent.  Thank you.

Lucinda
  ----- Original Message -----
  From: Peck, Jon<mailto:[hidden email]>
  To: [hidden email]<mailto:[hidden email]>
  Sent: Wednesday, August 13, 2008 7:27 PM
  Subject: Re: creating multiple charts with chart builder


  Python string substitution works much better than macro with GPL.  You can find an example of a chart generated this way in the paretochart.py module downloadable from SPSS Developer Central (www.spss.com/devcentral<http://www.spss.com/devcentral>) or in the pls.py module installed when you install the Partial Least Squares addon for SPSS 16.  But these do require some Python knowledge.

  As a general approach, I would define a Python function whose arguments are the parameters you want to substitute in GGRAPH/GPL, make a template of the syntax you want, and pass it the parameters.  If this is all Greek to you, though, this might not be the shortest route to a solution.

  HTH,
  Jon Peck

  -----Original Message-----
  From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of LUCINDA M TEAR
  Sent: Wednesday, August 13, 2008 6:21 PM
  To: [hidden email]<mailto:[hidden email]>
  Subject: Re: [SPSSX-L] creating multiple charts with chart builder

  Thank you, ViAnn for your help re: outlier labels.  My variable names (actually, I have 19 - more than I thought!) do have common names:  chem1 to chem19.  I tried using the !concat() function and creating a (define - !enddefine) macro, but that didn't work.  The syntax guide for ggraph indicates that name can be used to create multiple graphs with the same syntax, but doesn't provide any examples of that....

  Thanks again!

  Lucinda


  ----- Original Message -----
    From: ViAnn Beadle<mailto:[hidden email]<mailto:[hidden email]>>
    To: [hidden email]<mailto:[hidden email]<mailto:[hidden email]%3Cmailto:[hidden email]>>
    Sent: Wednesday, August 13, 2008 4:57 PM
    Subject: Re: creating multiple charts with chart builder


    When Chart Builder creates syntax, it knows what the variable label for the
    selected variable is and uses that when generating the GUIDE statement.
    Unlike Chart Builder, macros are simple substitutions of strings and have no
    direct knowledge of dictionary information. I have seen some solutions in
    which SPSS itself is coaxed into writing a macro with dictionary information
    within it but I haven't a clue as to how to go about this.

    It's fairly easy to use python to retrieve a variable label from a variable
    name and place that in the middle of the label function on the GUIDE
    statement. However, I don't think that you can embed a python program inside
    of a macro used to generate 11 separate instances of the GGRAPH command. You
    might be able to use a python program which does the looping through the
    names and I'm sure that python fans on the list can come up with something
    that works.

    Tell us more about your sets of 11 variables. Do they have some common name
    part to them such as chem1 to chem11?

    On a simpler note, to suppress the outlier labels, omit the label(id)
    function from your ELEMENT statement and drop the DATA statement defining
    the id variable.

    -----Original Message-----
    From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
    LUCINDA M TEAR
    Sent: Wednesday, August 13, 2008 5:29 PM
    To: [hidden email]<mailto:[hidden email]<mailto:[hidden email]%3Cmailto:[hidden email]>>
    Subject: creating multiple charts with chart builder

    Hello,

    I am just venturing into Chart Builder instead of using Interactive Charts
    because I want to be able to use the "logarithmic" axis transformation on
    the scale axis when I am creating a set of multiple boxplots.

    I have read the syntax help, but I am not sure how to create a "macro" that
    will allow me create multiple boxplots, one for each of 11 variables, such
    that each boxplot uses the variable LABEL name as the axis label and does
    NOT include labels for outliers.

    I have the following syntax - I have tried to use the "NAME=" function so
    that I would have to change only the variable name after the VARIABLES =
    command, but this doesn't work to change the axis label and I'm not sure how
    to get it to read a list of variable names so that several boxplots are
    created.

    Any help would be appreciated!  Thank you,  Lucinda Tear

    * Chart Builder.

    GGRAPH

    /GRAPHDATASET NAME="graphdataset" VARIABLES=chem1 [NAME="chem"]
    MISSING=VARIABLEWISE

    REPORTMISSING=NO

    /GRAPHSPEC SOURCE=INLINE

    TEMPLATE=["C:\Program Files\SPSS\Looks\air_boxes.sgt"].

    BEGIN GPL

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

    DATA: chem=col(source(s), name("chem")) #I replaced chem1 with "chem" here
    to try to make it more generic

    DATA: id=col(source(s), name("$CASENUM"), unit.category())

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

    GUIDE: axis(dim(1), label("WHAT CAN I PUT HERE SO THAT THE AXIS LABEL NAME
    CHANGES WITH EACH VARIABLE"))

    SCALE: log(dim(1), base(10))

    ELEMENT: schema(position(bin.quantile.letter(chem)), label(id)) #I replaced
    chem1 with "chem" here to try to make it more generic

    END GPL.

    =======
    To manage your subscription to SPSSX-L, send a message to
    [hidden email]<mailto:[hidden email]<mailto:[hidden email]%3Cmailto:[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]<mailto:[hidden email]<mailto:[hidden email]%3Cmailto:[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]<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]<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
Reply | Threaded
Open this post in threaded view
|

Re: creating multiple charts with chart builder

Peck, Jon
Here is an example of parameterizing a chart specification.

 

I created a Python module named chartlib containing a function named shadedscatter.  You might build up a whole library of functions like this in your chartlib module.

 

The code for the function is below.  You could save this as chartlib.py in c:/python25/lib/site-packages if you have a standard Python installation.

(This requires that you have installed the Python plugin and, if you have an oldish SPSS version, that you download spssaux.py from Developer Central, www.spss.com/devcentral).

 

In the function, the parameters x, y, and z are inserted into the GGRAPH and GPL syntax by referring to them as

%(x)s and similar.

 

The function looks up the variable labels and inserts them where needed.

 

To use this function, you would write something like this using the cars.sav dataset shipped with SPSS.

 

begin program.

import chartlib

chartlib.shadedscatter(y="mpg", x="accel", z="engine")

end program.

 

Note that in Python code, case and indentation matter.

 

HTH,

Jon Peck

 

(If the listserv mangles the code below, I can email it to anyone who wants it.)

 

--------- start of shadedscatter function definition

 

# graphics function that parameterizes a chart

import spss, spssaux

 

def shadedscatter(y, x, z):

    """Create a scatterplot of y by x with point color determined by variable z.

   

    Use variable labels for labeling the chart"""

   

    vardict = spssaux.VariableDict([x, y, z])

    xlabel = vardict[x].VariableLabel

    ylabel = vardict[y].VariableLabel

    zlabel = vardict[z].VariableLabel

   

    cmd=r"""GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=%(y)s %(x)s %(z)s MISSING=LISTWISE

  REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

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

  DATA: x=col(source(s), name("%(x)s"))

  DATA: y=col(source(s), name("%(y)s"))

  DATA: z=col(source(s), name("%(z)s"))

  GUIDE: axis(dim(1), label("%(xlabel)s"))

  GUIDE: axis(dim(2), label("%(ylabel)s"))

  GUIDE: legend(aesthetic(aesthetic.color), label("%(zlabel)s"))

  ELEMENT: point(position(x*y), color(z))

END GPL.""" % locals()

spss.Submit(cmd)

 

 

 

 

________________________________

From: LUCINDA M TEAR [mailto:[hidden email]]
Sent: Wednesday, August 13, 2008 10:46 PM
To: Peck, Jon; [hidden email]
Subject: Re: Re: creating multiple charts with chart builder

 

Thank you, Jon!  The general terms are not Greek, but I don't know Python, so I'll see if I can decipher the link you sent.  Thank you.

 

Lucinda

        ----- Original Message -----

        From: Peck, Jon <mailto:[hidden email]>  

        To: [hidden email]

        Sent: Wednesday, August 13, 2008 7:27 PM

        Subject: Re: creating multiple charts with chart builder

         

        Python string substitution works much better than macro with GPL.  You can find an example of a chart generated this way in the paretochart.py module downloadable from SPSS Developer Central (www.spss.com/devcentral) or in the pls.py module installed when you install the Partial Least Squares addon for SPSS 16.  But these do require some Python knowledge.
       
        As a general approach, I would define a Python function whose arguments are the parameters you want to substitute in GGRAPH/GPL, make a template of the syntax you want, and pass it the parameters.  If this is all Greek to you, though, this might not be the shortest route to a solution.
       
        HTH,
        Jon Peck
       
        -----Original Message-----
        From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of LUCINDA M TEAR
        Sent: Wednesday, August 13, 2008 6:21 PM
        To: [hidden email]
        Subject: Re: [SPSSX-L] creating multiple charts with chart builder
       
        Thank you, ViAnn for your help re: outlier labels.  My variable names (actually, I have 19 - more than I thought!) do have common names:  chem1 to chem19.  I tried using the !concat() function and creating a (define - !enddefine) macro, but that didn't work.  The syntax guide for ggraph indicates that name can be used to create multiple graphs with the same syntax, but doesn't provide any examples of that....
       
        Thanks again!
       
        Lucinda
       
       
        ----- Original Message -----
          From: ViAnn Beadle<mailto:[hidden email]>
          To: [hidden email]<mailto:[hidden email] <mailto:[hidden email]%3cmailto:[hidden email]> >
          Sent: Wednesday, August 13, 2008 4:57 PM
          Subject: Re: creating multiple charts with chart builder
       
       
          When Chart Builder creates syntax, it knows what the variable label for the
          selected variable is and uses that when generating the GUIDE statement.
          Unlike Chart Builder, macros are simple substitutions of strings and have no
          direct knowledge of dictionary information. I have seen some solutions in
          which SPSS itself is coaxed into writing a macro with dictionary information
          within it but I haven't a clue as to how to go about this.
       
          It's fairly easy to use python to retrieve a variable label from a variable
          name and place that in the middle of the label function on the GUIDE
          statement. However, I don't think that you can embed a python program inside
          of a macro used to generate 11 separate instances of the GGRAPH command. You
          might be able to use a python program which does the looping through the
          names and I'm sure that python fans on the list can come up with something
          that works.
       
          Tell us more about your sets of 11 variables. Do they have some common name
          part to them such as chem1 to chem11?
       
          On a simpler note, to suppress the outlier labels, omit the label(id)
          function from your ELEMENT statement and drop the DATA statement defining
          the id variable.
       
          -----Original Message-----
          From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
          LUCINDA M TEAR
          Sent: Wednesday, August 13, 2008 5:29 PM
          To: [hidden email]<mailto:[hidden email] <mailto:[hidden email]%3cmailto:[hidden email]> >
          Subject: creating multiple charts with chart builder
       
          Hello,
       
          I am just venturing into Chart Builder instead of using Interactive Charts
          because I want to be able to use the "logarithmic" axis transformation on
          the scale axis when I am creating a set of multiple boxplots.
       
          I have read the syntax help, but I am not sure how to create a "macro" that
          will allow me create multiple boxplots, one for each of 11 variables, such
          that each boxplot uses the variable LABEL name as the axis label and does
          NOT include labels for outliers.
       
          I have the following syntax - I have tried to use the "NAME=" function so
          that I would have to change only the variable name after the VARIABLES =
          command, but this doesn't work to change the axis label and I'm not sure how
          to get it to read a list of variable names so that several boxplots are
          created.
       
          Any help would be appreciated!  Thank you,  Lucinda Tear
       
          * Chart Builder.
       
          GGRAPH
       
          /GRAPHDATASET NAME="graphdataset" VARIABLES=chem1 [NAME="chem"]
          MISSING=VARIABLEWISE
       
          REPORTMISSING=NO
       
          /GRAPHSPEC SOURCE=INLINE
       
          TEMPLATE=["C:\Program Files\SPSS\Looks\air_boxes.sgt"].
       
          BEGIN GPL
       
          SOURCE: s=userSource(id("graphdataset"))
       
          DATA: chem=col(source(s), name("chem")) #I replaced chem1 with "chem" here
          to try to make it more generic
       
          DATA: id=col(source(s), name("$CASENUM"), unit.category())
       
          COORD: rect(dim(1), transpose())
       
          GUIDE: axis(dim(1), label("WHAT CAN I PUT HERE SO THAT THE AXIS LABEL NAME
          CHANGES WITH EACH VARIABLE"))
       
          SCALE: log(dim(1), base(10))
       
          ELEMENT: schema(position(bin.quantile.letter(chem)), label(id)) #I replaced
          chem1 with "chem" here to try to make it more generic
       
          END GPL.
       
          =======
          To manage your subscription to SPSSX-L, send a message to
          [hidden email]<mailto:[hidden email] <mailto:[hidden email]%3cmailto:[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]<mailto:[hidden email] <mailto:[hidden email]%3cmailto:[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