<?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: Increase spacing in SGPLOT legend in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671580#M20271</link>
    <description>&lt;P&gt;If you are using a formatted numeric variable to get your drug names, then you will need to modify the approach accordingly.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jul 2020 19:57:33 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2020-07-22T19:57:33Z</dc:date>
    <item>
      <title>Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671493#M20263</link>
      <description>&lt;DIV&gt;&lt;DIV class="resolved"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="resolved"&gt;&lt;SPAN style="font-family: inherit;"&gt;I have created the graph below with SGPLOT and need to increase the spacing between the legend markers and the value labels. I can't find an argument for the keylegend statement that will allow me to do this. Any suggestions?&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="graph example.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47514i93C293F2C2E9B97C/image-size/large?v=v2&amp;amp;px=999" role="button" title="graph example.png" alt="graph example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Jul 2020 17:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671493#M20263</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-22T17:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671525#M20265</link>
      <description>&lt;P&gt;I don't know. I don't remember anything like that. The first thing I would try is adding one or more nonbreaking spaces to the end of the drug name in a DATA step before you run sgplot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;drug = trim(drug) || 'A0'x;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 18:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671525#M20265</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2020-07-22T18:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671574#M20269</link>
      <description>That syntax deleted the numeric values of my variables, strange.</description>
      <pubDate>Wed, 22 Jul 2020 19:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671574#M20269</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-22T19:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671580#M20271</link>
      <description>&lt;P&gt;If you are using a formatted numeric variable to get your drug names, then you will need to modify the approach accordingly.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 19:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671580#M20271</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2020-07-22T19:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671582#M20272</link>
      <description>Yes I am using a separate numeric variable for each series on the graph.</description>
      <pubDate>Wed, 22 Jul 2020 20:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671582#M20272</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-22T20:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671590#M20273</link>
      <description>&lt;P&gt;I might be tempted to try something like&lt;/P&gt;
&lt;P&gt;Keylegend / across=3 down=2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and maybe play around with the LINELENGTH option to see about making the length of the lines shorter.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 20:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671590#M20273</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-22T20:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671595#M20274</link>
      <description>That may be an option, but I'd really prefer the legend to all be on 1 line if possible.</description>
      <pubDate>Wed, 22 Jul 2020 20:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671595#M20274</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-22T20:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671612#M20276</link>
      <description>&lt;P&gt;I am sure it can be done.&amp;nbsp; Can you share your code and data (dummied up if it's confidential)&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 20:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671612#M20276</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-07-22T20:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671625#M20277</link>
      <description>If your variables are numeric, then you can do something like the following in a data step:&lt;BR /&gt;&lt;BR /&gt;drug2='A0A0'x||strip(vvalue(drug))||'A0A0'x;&lt;BR /&gt;&lt;BR /&gt;Where the number of A0 that you repeat will be the number of non-breaking spaces you add to the value.  You would then group by DRUG2 instead of drug.</description>
      <pubDate>Wed, 22 Jul 2020 21:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671625#M20277</guid>
      <dc:creator>JeffMeyers</dc:creator>
      <dc:date>2020-07-22T21:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671643#M20278</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228746"&gt;@martyvd&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;That may be an option, but I'd really prefer the legend to all be on 1 line if possible.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is only so much space available. If the values are long enough there just is not much space left between the lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try anything with the LINELENGTH to shorten the displayed line segments in the legend?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 00:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671643#M20278</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-23T00:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671815#M20283</link>
      <description>Yes, decreasing the LINELENGTH value only shortens the line segments, it does not affect the spacing between the line segments and the labels.</description>
      <pubDate>Thu, 23 Jul 2020 13:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671815#M20283</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-23T13:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671820#M20286</link>
      <description>You may want to consider why you want to increase the space between the&lt;BR /&gt;chicklet and the label.  As Rick suggested, you would have to add a NBSP&lt;BR /&gt;space before each value of group values to add some white space.&lt;BR /&gt;&lt;BR /&gt;Or, if you want to make the legend more bolder, you can use KEYLEGEND&lt;BR /&gt;options to adjust the size of the chicklets - FILLASPECT, FILLHEIGHT, SCALE.&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2020 13:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671820#M20286</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2020-07-23T13:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671821#M20287</link>
      <description>&lt;DIV&gt;&lt;DIV class="resolved"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="resolved"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=prim_sub_use noborder nowall description='Primary substance use at admission, 2007-2017';
series x=Year y=Alcohol/markers markerattrs=(symbol=CircleFilled color='#0060A9' size=12) lineattrs=(color='#0060A9' thickness=3);
series x=Year y=Opiates/markers markerattrs=(symbol=TriangleDownFilled size=12 color='#ed1c24') lineattrs=(color='#ed1c24' thickness=3 pattern=solid);
series x=Year y=Cocaine/markers markerattrs=(symbol=SquareFilled color='#ffc222' size=12) lineattrs=(color='#ffc222' thickness=3 pattern=solid);
series x=Year y=Marijuana/markers markerattrs=(symbol=DiamondFilled color='#64c069' size=12) lineattrs=(color='#64c069' thickness=3 pattern=solid) legendlabel="Marijuana/hashish";
series x=Year y=Methamphetamine_amphetamines/markers markerattrs=(symbol=TriangleFilled size=12 color='#00a2e5') lineattrs=(color='#00a2e5' thickness=3 pattern=solid);
yaxis label='Percent of all admissions aged 12 years and older' VALUES = (0 TO 50 BY 10) offsetmax=0 offsetmin=0;
xaxis label='Admission Year' VALUES = (2007 TO 2017 BY 1) display=(nolabel noticks);
keylegend/noborder linelength=30;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="resolved"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Jul 2020 13:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671821#M20287</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-23T13:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671826#M20288</link>
      <description>I tried adding a space to the variables using Jeff's code, but the graph was blank when I used the new variables.</description>
      <pubDate>Thu, 23 Jul 2020 14:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671826#M20288</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-23T14:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671855#M20290</link>
      <description>&lt;P&gt;The NBSP suggestion originally came from Warren.&amp;nbsp; Sorry about the incorrect attribution.&lt;/P&gt;
&lt;P&gt;Also, my suggested usage of KEYLEGEND options may be more applicable for filled chicklets.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 15:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671855#M20290</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2020-07-23T15:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671864#M20291</link>
      <description>&lt;P&gt;I assigned labels however, I left your code 99% intact but wrapped inside an absolute layout (could use gridded also) and specified the dimension that you can change.&amp;nbsp; You did not specify the output format so I picked pdf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Untitled.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47602i94F31F93B8E9495C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data prim_sub_use; set xl.sheet1; 
label 
Alcohol	='^_^_Alcohol^_'
Opiates	='^_^_Opiates^_'
Cocaine	='^_^_Cocaine^_'
Marijuana='^_^_Marijuana/hashish^_'
Methamphetamine_amphetamines='^_Methamphetamine/amphetamines^_'
;
run;
ods escapechar='^';
ods _all_ close;
options nonumber nodate orientation=landscape papersize=letter nocenter
	leftmargin=.5in rightmargin=.5in topmargin=.5in bottommargin=.5in;
ods pdf file="~/img/abuse.pdf" dpi=300 notoc;
ods layout absolute;
ods region x=0in y=0in width=10in;
ods graphics on /noborder height=7.5in width=10in scale=on;
proc sgplot data=prim_sub_use noborder nowall 
		description='Primary substance use at admission, 2007-2017';
	series x=Year y=Alcohol/markers markerattrs=(symbol=CircleFilled 
		color='#0060A9' size=12) lineattrs=(color='#0060A9' thickness=3);
	series x=Year y=Opiates/markers markerattrs=(symbol=TriangleDownFilled size=12 
		color='#ed1c24') lineattrs=(color='#ed1c24' thickness=3 pattern=solid);
	series x=Year y=Cocaine/markers markerattrs=(symbol=SquareFilled 
		color='#ffc222' size=12) lineattrs=(color='#ffc222' thickness=3 
		pattern=solid);
	series x=Year y=Marijuana/markers markerattrs=(symbol=DiamondFilled 
		color='#64c069' size=12) lineattrs=(color='#64c069' thickness=3 
		pattern=solid) ; * legendlabel="Marijuana/hashish";
	series x=Year y=Methamphetamine_amphetamines/markers 
		markerattrs=(symbol=TriangleFilled size=12 color='#00a2e5') 
		lineattrs=(color='#00a2e5' thickness=3 pattern=solid);
	yaxis label='Percent of all admissions aged 12 years and older' VALUES=(0 TO 50 BY 10) offsetmax=0 offsetmin=0;
	xaxis label='Admission Year' VALUES=(2007 TO 2017 BY 1) display=(nolabel 		noticks);
	keylegend/noborder linelength=30;
run;
ods graphics off;
ods layout end;
ods pdf close;
ods _ALL_ CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 15:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671864#M20291</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-07-23T15:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671919#M20292</link>
      <description>Thanks, I think this will work for me.</description>
      <pubDate>Thu, 23 Jul 2020 18:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671919#M20292</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-23T18:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671923#M20293</link>
      <description>It added a light gray border despite containing the noborder option. Is there a different option I need to use to remove it?</description>
      <pubDate>Thu, 23 Jul 2020 19:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671923#M20293</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-23T19:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671930#M20295</link>
      <description>&lt;P&gt;See attached.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 19:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671930#M20295</guid>
      <dc:creator>martyvd</dc:creator>
      <dc:date>2020-07-23T19:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Increase spacing in SGPLOT legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671936#M20296</link>
      <description>perhaps in the ods region line add &lt;BR /&gt;style=[borderwidth=1 bordercolor=white];</description>
      <pubDate>Thu, 23 Jul 2020 19:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Increase-spacing-in-SGPLOT-legend/m-p/671936#M20296</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-07-23T19:36:51Z</dc:date>
    </item>
  </channel>
</rss>

