Formatting Graphs to Zero Decimal places

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

Formatting Graphs to Zero Decimal places

YvonneM

Hi there!  I’m having trouble formatting a graph’s axis and the count/percent labels.  My graph reports percentages. 

 

I can’t get the Y axis to show 0 decimals and likewise for the percents that I put on my bars.   I would like to do this all with syntax instead of manually clicking on the output to fix these formatting issues because I’m creating and automating many charts using Production Facility. 

 

Following is what my syntax looks like.  I know there are a lot of “counts” in there, but the graph is still showing the correct percentages. 

 

GGRAPH   /GRAPHDATASET NAME="graphdataset" VARIABLES=PCPr COUNT()[name="COUNT"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE inlinetemplate=

"<addDataLabels><labeling variable='percent'></labeling></addDataLabels>".

BEGIN GPL

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

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

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

  GUIDE: axis(dim(1), label("Primary Care Provider"))

 GUIDE: axis(dim(2), label("% Compliant"))

  GUIDE: text.title(label("Child/Adolescent Screening by Provider"))

  GUIDE: text.subtitle(label("Percents less than 2% collapsed into 'Other'"))

  SCALE: linear(dim(2), include(0))

  TRANS: PCPr_TRANS = collapse(category(PCPr), minimumPercent(2), sumVariable(COUNT), otherValue("Other"))

  ELEMENT: interval(position(summary.percent(PCPr_TRANS*COUNT, base.all(acrossPanels()))), shape.interior(shape.square))

END GPL.

 

Thank you in advance for your help!

Yvonne

 

CONFIDENTIALITY NOTICE: This e-mail and any attachments are intended only for the use of the individual to whom (or entity to which) the e-mail is addressed and may contain information that is protected, privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of the communication is strictly prohibited. If you think you have received this communication in error, please notify the sender immediately. ===================== 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: Formatting Graphs to Zero Decimal places

Jignesh Sutar
I believe GGRAPH will display the values of the axis in the format that is in already present in the data, which can be changed using the FORMATS command:

FORMATS
  v1 (f8.0) /* zero decimal point float */
  v2 (pct3.0) /* zero decimal percentage */ .


Cheers
Jignesh

Reply | Threaded
Open this post in threaded view
|

Re: Formatting Graphs to Zero Decimal places

YvonneM
Hi Jignesh,

Thanks for your reply.  My values are raw, in counts, but I'm asking to represent these values in percents via the graph.  I tried formatting the variable being graphed as you suggested, but I still get 2 decimal places.  Any other ideas?

C. Yvonne Montejano, MPAff
Data Application Analyst, Information Services
People's Community Clinic
(512) 684-1706


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jignesh Sutar
Sent: Tuesday, October 14, 2014 10:10 AM
To: [hidden email]
Subject: Re: Formatting Graphs to Zero Decimal places

I believe GGRAPH will display the values of the axis in the format that is in already present in the data, which can be changed using the FORMATS command:

FORMATS
  v1 (f8.0) /* zero decimal point float */
  v2 (pct3.0) /* zero decimal percentage */ .


Cheers
Jignesh





--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Formatting-Graphs-to-Zero-Decimal-places-tp5727577p5727578.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
CONFIDENTIALITY NOTICE: This e-mail and any attachments are intended only for the use of the individual to whom (or entity to which) the e-mail is addressed and may contain information that is protected, privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of the communication is strictly prohibited. If you think you have received this communication in error, please notify the sender immediately.

=====================
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: Formatting Graphs to Zero Decimal places

PRogman
If you use this expanded line in the inlinetemplate statement it should work. Beware if the command line gets too long...
   INLINETEMPLATE="<addDataLabels><labeling variable='percent'></labeling></addDataLabels><setTickLabelFormat categorical='false' derived='false' role='y'><format maximumFractionDigits='0' minimumFractionDigits='0' suffix='%'/></setTickLabelFormat>".
Personally I prefer the documented subcommand TEMPLATE=["path/template1.sgt" "path/template2.sgt"]. Note that templates are applied in order of definition, after the graph is generated with defaults.
Create and save your template when your graph looks OK.
Define a FILE HANDE  to the folder where all (reusable) templates are saved (change it to suit your work). I usually place it near the top of the syntax file where it is easily changed if files are moved or folder renamed.
FILE HANDLE fpMyTemplates /NAME="%userprofile%\Documents\mySPSSTemplates".
When your GGraph command is pasted or written, add or edit the TEMPLATE specification. Apparently both TEMPLATE and INLINETEMPLATE can coexist.
  /GRAPHSPEC
   SOURCE=INLINE
   TEMPLATE=["fpMyTemplates\YScalePercent.sgt"]
   inlinetemplate="<addDataLabels><labeling variable='percent'></labeling></addDataLabels>".
 
I edited my template file and removed everything but the important stuff. This is it (including major ticks at 10's and minor ticks at 5's:

File 'YScalePercent.sgt':
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<template SPSS-Version="2.9"
          date="2013-09-27"
          description="Y-scale: percent in 10% interval. Data in 0-100"
          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.4.xsd">
        <setTickLabelFormat categorical="false"
                            derived="false"
                            role="y">
                <format maximumFractionDigits="0"
                        minimumFractionDigits="0"
                        suffix="%"/>
        </setTickLabelFormat>
        <setAxisMajorTicks>
                <majorTicks categorical="false"
                            delta="10"
                            role="y"/>
        </setAxisMajorTicks>
        <setAxisMinorTicks>
                <minorTicks categorical="false"
                            number="2"
                            role="y"/>
        </setAxisMinorTicks>
</template>

HTH, PR