<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HBARs with left justified tick labels in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16729#M339</link>
    <description>A little follow-up on the annotate solution -- for those of you that don't want to run the code to see what the graph looks like, here's a link to the output on an easy-to-view webpage:&lt;BR /&gt;
&lt;BR /&gt;
   &lt;A href="http://robslink.com/SAS/democd42/bar_table.htm" target="_blank"&gt;http://robslink.com/SAS/democd42/bar_table.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
And a link to the sas code:&lt;BR /&gt;
&lt;BR /&gt;
   &lt;A href="http://robslink.com/SAS/democd42/bar_table_info.htm" target="_blank"&gt;http://robslink.com/SAS/democd42/bar_table_info.htm&lt;/A&gt;</description>
    <pubDate>Tue, 08 Dec 2009 16:30:30 GMT</pubDate>
    <dc:creator>GraphGuy</dc:creator>
    <dc:date>2009-12-08T16:30:30Z</dc:date>
    <item>
      <title>HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16722#M332</link>
      <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to replicate a PDF (from Excel) report in SAS 9.2 and I haven't found the best solution although there seem to be many possible approaches.&lt;BR /&gt;
&lt;BR /&gt;
The single page PDF report contains 3 small tables and a table with data and horizontal bars with percentages. The tables / reports are no problem but I haven't figured out how to create a table with horizontal bars that looks good.  I found an example in a link posed by Sanjay in the beginning of this forum which has almost what I'm trying to get - a table of statistics with hbars with golf data.&lt;BR /&gt;
&lt;BR /&gt;
The structure of the example has columns with age, events, wins, player's name, and earnings in a hbar chart. My data are similar but the player's name column needs to be the left most column and left justified. It seems that there are no options to change it from right justified. This looks like the conclusion in the thread "SGPLOT: Wrap &amp;amp; Left Justify Tickmark Values" from Oct 8th.&lt;BR /&gt;
&lt;BR /&gt;
One workaround is to use a monospace font and make the names the same length. This aligns the data to the left, but it doesn't look very good.&lt;BR /&gt;
&lt;BR /&gt;
I also thought of an alternative based on traffic lighting examples. If it's possible to control the formatting of a cell, I shoulld be able to  create a table template if I can find a character format to simulate bars. &lt;BR /&gt;
&lt;BR /&gt;
Can anyone think of a better way or is the only alternative to send the data to Excel and format it there? &lt;BR /&gt;
&lt;BR /&gt;
Thanks for any advice&lt;BR /&gt;
Ed</description>
      <pubDate>Fri, 13 Nov 2009 17:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16722#M332</guid>
      <dc:creator>EdB</dc:creator>
      <dc:date>2009-11-13T17:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16723#M333</link>
      <description>Hmm ... this forum _really_ needs a way to post up attachments, eh!?!</description>
      <pubDate>Fri, 13 Nov 2009 18:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16723#M333</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2009-11-13T18:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16724#M334</link>
      <description>I'm confused...you want something like what's produced by the program in this posting, only an HBAR instead of VBAR???&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=26551枷" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=26551枷&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 13 Nov 2009 20:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16724#M334</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-11-13T20:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16725#M335</link>
      <description>Hi,&lt;BR /&gt;
I want this with left justified names.&lt;BR /&gt;
Ed&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/35/135.html" target="_blank"&gt;http://support.sas.com/kb/35/135.html&lt;/A&gt;</description>
      <pubDate>Fri, 13 Nov 2009 21:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16725#M335</guid>
      <dc:creator>EdB</dc:creator>
      <dc:date>2009-11-13T21:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16726#M336</link>
      <description>EdB,&lt;BR /&gt;
&lt;BR /&gt;
The example you point to uses the new "proc template" and "proc sgrender".&lt;BR /&gt;
I'm not an expert at that, so I'm not sure if you can control the justification there.&lt;BR /&gt;
&lt;BR /&gt;
But I have re-written the example, using traditional "old school" SAS/Graph&lt;BR /&gt;
proc gchart, with the table programmatically annotated to the side, and&lt;BR /&gt;
you can easily control the justification of the player names (ie, bar labels)&lt;BR /&gt;
using the axis statement:&lt;BR /&gt;
&lt;BR /&gt;
   axis1 label=none value=(justify=left);&lt;BR /&gt;
&lt;BR /&gt;
Here's the complete code for my re-write:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data PGA2007;&lt;BR /&gt;
  input Rank 2.  Player &amp;amp; $15. Age Events Rounds CutsMade Top10 Wins Earnings;&lt;BR /&gt;
  retain Constant 1;&lt;BR /&gt;
  label CutsMade="Cuts Made" Top10="Top 10s";&lt;BR /&gt;
  format Earnings dollar12.;&lt;BR /&gt;
  format age events wins 3.0;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
 1 Tiger Woods     33  16  61 16 12  7 10867052&lt;BR /&gt;
 2 Phil Mickelson  38  22  73 16  7  3  5819988&lt;BR /&gt;
 3 Vijay Singh     45  27 101 25  7  2  4728377&lt;BR /&gt;
 4 Steve Stricker  41  23  80 19  9  1  4663077&lt;BR /&gt;
 5 K.J. Choi       38  25  88 20  7  2  4587859&lt;BR /&gt;
 6 Rory Sabbatini  32  23  80 18 10  1  4550040&lt;BR /&gt;
 7 Jim Furyk       38  24  84 20  8  1  4154046&lt;BR /&gt;
 8 Zach Johnson    32  23  78 18  5  2  3922338&lt;BR /&gt;
 9 Sergio Garcia   29  19  67 16  7  0  3721185&lt;BR /&gt;
10 Aaron Baddeley  27  23  82 19  7  1  3441119&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data my_anno; set PGA2007;&lt;BR /&gt;
length text $50 style $20;&lt;BR /&gt;
function='label'; style='"arial"'; hsys='3'; when='a';&lt;BR /&gt;
ysys='2'; midpoint=Player;&lt;BR /&gt;
/* annotate totals at end of bars */&lt;BR /&gt;
xsys='2'; position='6';&lt;BR /&gt;
text='  '||trim(left(put(Earnings,dollar12.)));&lt;BR /&gt;
output;&lt;BR /&gt;
/* annotate the values for the table to the left of the bar chart */&lt;BR /&gt;
xsys='3'; position='5';&lt;BR /&gt;
x=5; text=trim(left(Age)); output;&lt;BR /&gt;
x=12; text=trim(left(Events)); output;&lt;BR /&gt;
x=19; text=trim(left(Wins)); output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data headings;&lt;BR /&gt;
length text $50 style $20;&lt;BR /&gt;
function='label'; style='"arial/bold"'; hsys='3'; when='a';&lt;BR /&gt;
/* annotate the headings for the table to the left of the bar chart */&lt;BR /&gt;
xsys='3'; position='5';&lt;BR /&gt;
ysys='3'; y=90;&lt;BR /&gt;
x=5; text="Age"; output;&lt;BR /&gt;
x=12; text="Events"; output;&lt;BR /&gt;
x=19; text="Wins"; output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* combine all your anno stuff */&lt;BR /&gt;
data my_anno; set my_anno headings;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
goptions ftitle="arial/bold" ftext="arial" gunit=pct htitle=4 htext=2.25;&lt;BR /&gt;
&lt;BR /&gt;
/* control left/right/center justification of Player name here! */&lt;BR /&gt;
axis1 label=none value=(justify=left);&lt;BR /&gt;
&lt;BR /&gt;
axis2 label=(font="arial/bold" "Earnings") minor=none offset=(0,0);&lt;BR /&gt;
&lt;BR /&gt;
title1 "Professional Golf Statistics for 2007";&lt;BR /&gt;
/* fake/blank title, to add white space on the left (don't try it with dev=java or activex!) */&lt;BR /&gt;
title2 angle=90 height=30pct " ";&lt;BR /&gt;
&lt;BR /&gt;
pattern1 v=s c=cx9BC4E2;&lt;BR /&gt;
&lt;BR /&gt;
proc gchart data=PGA2007 anno=my_anno;&lt;BR /&gt;
hbar Player / type=sum sumvar=Earnings descending nostats&lt;BR /&gt;
 maxis=axis1&lt;BR /&gt;
 raxis=axis2&lt;BR /&gt;
 autoref cref=graydd clipref&lt;BR /&gt;
 ;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]

added 'pre' tags around code, as recommended by Peter C.&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Robert Allison @ SAS</description>
      <pubDate>Mon, 16 Nov 2009 20:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16726#M336</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2009-11-16T20:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16727#M337</link>
      <description>very impressive implementation.&lt;BR /&gt;
but beware, ....&lt;BR /&gt;
when test running code copied from the message, "age" is pulled into the player name. The conflict was between forum message handling (equivalent of left(compbl(code))  )  and the  format modifier &amp;amp; [accepting a single blank within a string, requires double blank to terminate string]. In fact more than age might be pulled into name, as the 15 characters starting at the beginning of the name will be swallowed as "Player"&lt;BR /&gt;
&lt;I&gt;recommendation&lt;/I&gt; (&lt;B&gt;1&lt;/B&gt;) post unalterable code within [pre [/pre tags  or (&lt;B&gt;2&lt;/B&gt;) ensure strings that require the "&amp;amp;" input modifier appear last, or (&lt;B&gt;3&lt;/B&gt;) lobby for a [code tag that more easily pastes into SAS (not needing to be pasted into wordpad first)

Message was edited by: Peter.C</description>
      <pubDate>Mon, 23 Nov 2009 14:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16727#M337</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-23T14:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with right justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16728#M338</link>
      <description>Hi:&lt;BR /&gt;
&lt;BR /&gt;
I just wanted to follow up on this.  I saw the notes on using annotate - forgot about this approach entirely. My opinion is that you can do almost anything with it but it's more complex and requires different skills and more training.&lt;BR /&gt;
&lt;BR /&gt;
The GTL workarounds seem to get close to my goal of left justifying a label.&lt;BR /&gt;
&lt;BR /&gt;
I began with the golf example  &lt;A href="http://support.sas.com/kb/35/135.html" target="_blank"&gt;http://support.sas.com/kb/35/135.html&lt;/A&gt; &lt;BR /&gt;
and made some minor tweaks  - the major one was adding another scatterchart with only a y2axis displayed.&lt;BR /&gt;
&lt;BR /&gt;
The one remaining issue is that the cell header for the first column doesn't display so I'm not done, but it's getting closer.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the feedback and if anyone has ideas on the cell header I'd sure like to hear them.&lt;BR /&gt;
Ed&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The code (with some minor tweaks).&lt;BR /&gt;
&lt;BR /&gt;
data PGA2007; &lt;BR /&gt;
  input Rank 2.  Player &amp;amp; $15. Age Events Rounds CutsMade Top10 Mistresses Earnings;&lt;BR /&gt;
  retain Constant 1;&lt;BR /&gt;
  format Earnings dollar12.;  &lt;BR /&gt;
  format age events Mistresses 3.0;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
 1 Tiger Woods     33  16  61 16 12  9 10867052&lt;BR /&gt;
 2 Phil Mickelson  38  22  73 16  7  0  5819988&lt;BR /&gt;
 3 Vijay Singh     45  27 101 25  7  0  4728377&lt;BR /&gt;
 4 Steve Stricker  41  23  80 19  9  0  4663077&lt;BR /&gt;
 5 K.J. Choi       38  25  88 20  7  0  4587859&lt;BR /&gt;
 6 Rory Sabbatini  32  23  80 18 10  0  4550040&lt;BR /&gt;
 7 Jim Furyk       38  24  84 20  8  0  4154046&lt;BR /&gt;
 8 Zach Johnson    32  23  78 18  5  0  3922338&lt;BR /&gt;
 9 Sergio Garcia   29  19  67 16  7  0  3721185&lt;BR /&gt;
10 Aaron Baddeley  27  23  82 19  7  0  3441119&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%let standardopts=%str( walldisplay=none border=false&lt;BR /&gt;
                   yaxisopts=(display=none reverse=true type=discrete)&lt;BR /&gt;
                   xaxisopts=(display=none offsetmin=0.1 offsetmax=0) ); &lt;BR /&gt;
* options for all scatterplots;&lt;BR /&gt;
&lt;BR /&gt;
proc template;&lt;BR /&gt;
  define statgraph BarTableHorz;&lt;BR /&gt;
    begingraph / designwidth=600px designheight=400px;&lt;BR /&gt;
    entrytitle "Professional Golf Statistics for 2007";   &lt;BR /&gt;
    layout lattice / columns=5 columngutter=1 &lt;BR /&gt;
                     columnweights=(.20 .12 .12 .14 .42);&lt;BR /&gt;
	cell;                                                             /* column1: name */ &lt;BR /&gt;
	  cellheader;  entry halign=right  "Player";     endcellheader;&lt;BR /&gt;
      layout overlay  / &amp;amp;standardopts. y2axisopts=(reverse=true type=discrete);&lt;BR /&gt;
        scatterplot y=player x=constant  / markercharacter=Player &lt;BR /&gt;
                               markerattrs=(size=0) yaxis=y2;&lt;BR /&gt;
      endlayout;&lt;BR /&gt;
	endcell;&lt;BR /&gt;
	cell;                                                             /* data column */ &lt;BR /&gt;
	  cellheader;  entry halign=center "Age"  ;      endcellheader;&lt;BR /&gt;
      layout overlay  /  &amp;amp;standardopts. ;&lt;BR /&gt;
        scatterplot y=player x=constant  / markercharacter=age &lt;BR /&gt;
                            markerattrs=(size=0);&lt;BR /&gt;
      endlayout;&lt;BR /&gt;
	endcell;&lt;BR /&gt;
	cell;                                                            /* data column */ &lt;BR /&gt;
	  cellheader;  entry halign=center "Events";     endcellheader;&lt;BR /&gt;
      layout overlay  /  &amp;amp;standardopts. ;&lt;BR /&gt;
        scatterplot y=player x=constant  / markercharacter=events &lt;BR /&gt;
                           markerattrs=(size=0);&lt;BR /&gt;
      endlayout;&lt;BR /&gt;
	endcell;&lt;BR /&gt;
	cell;                                                            /* data column */ &lt;BR /&gt;
	  cellheader;  entry halign=center "Mistresses"; endcellheader;&lt;BR /&gt;
      layout overlay  /  &amp;amp;standardopts. ;&lt;BR /&gt;
        scatterplot y=player x=constant  / markercharacter=Mistresses &lt;BR /&gt;
                              markerattrs=(size=0);&lt;BR /&gt;
      endlayout;&lt;BR /&gt;
    endcell;&lt;BR /&gt;
	cell;                                                            /* barchart */ &lt;BR /&gt;
	  cellheader;  entry halign=center "Earnings" ;  endcellheader;&lt;BR /&gt;
      layout overlay  / walldisplay=none border=false &lt;BR /&gt;
                        yaxisopts=(reverse=true label=" " display=none)&lt;BR /&gt;
                        xaxisopts=(griddisplay=on labelattrs=(weight=bold)&lt;BR /&gt;
                        linearopts=(tickvalueformat=(extractscale=true)) );&lt;BR /&gt;
        barchart  x=player y=Earnings /orient=horizontal outlineattrs=(color=white);&lt;BR /&gt;
      endlayout;&lt;BR /&gt;
	endcell;&lt;BR /&gt;
  endlayout;&lt;BR /&gt;
  endgraph;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc template;&lt;BR /&gt;
  define Style BarTableHorzStyle;&lt;BR /&gt;
  parent = styles.journal;&lt;BR /&gt;
  style GraphFonts from GraphFonts / 'GraphDataFont' = (", ",10pt);&lt;BR /&gt;
  style graphaxislines from graphaxislines / contrastcolor=white;  &lt;BR /&gt;
        /* keep axis but hide it. it needs to exist to or the labels are centered */&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods pdf file="c:\temp\BarTableHorz4.pdf" style=BarTableHorzStyle;&lt;BR /&gt;
title; &lt;BR /&gt;
proc sgrender data=PGA2007 template=BarTableHorz;&lt;BR /&gt;
run;&lt;BR /&gt;
ods pdf close;</description>
      <pubDate>Tue, 08 Dec 2009 16:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16728#M338</guid>
      <dc:creator>EdB</dc:creator>
      <dc:date>2009-12-08T16:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: HBARs with left justified tick labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16729#M339</link>
      <description>A little follow-up on the annotate solution -- for those of you that don't want to run the code to see what the graph looks like, here's a link to the output on an easy-to-view webpage:&lt;BR /&gt;
&lt;BR /&gt;
   &lt;A href="http://robslink.com/SAS/democd42/bar_table.htm" target="_blank"&gt;http://robslink.com/SAS/democd42/bar_table.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
And a link to the sas code:&lt;BR /&gt;
&lt;BR /&gt;
   &lt;A href="http://robslink.com/SAS/democd42/bar_table_info.htm" target="_blank"&gt;http://robslink.com/SAS/democd42/bar_table_info.htm&lt;/A&gt;</description>
      <pubDate>Tue, 08 Dec 2009 16:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/HBARs-with-left-justified-tick-labels/m-p/16729#M339</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2009-12-08T16:30:30Z</dc:date>
    </item>
  </channel>
</rss>

