<?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: Proc SGplot - formatting X axis in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390012#M13359</link>
    <description>&lt;P&gt;Can't paste the plot here. Don't know how to present the plot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Main problem is - the values on x axis are concentrated near the centre, taking 1/3 of the total space on x axis. So the rest 2/3 are just empty. I want the values to be spread equally on the entire x axis&lt;/P&gt;</description>
    <pubDate>Tue, 22 Aug 2017 20:13:05 GMT</pubDate>
    <dc:creator>kingCobra</dc:creator>
    <dc:date>2017-08-22T20:13:05Z</dc:date>
    <item>
      <title>Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/389993#M13356</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see the attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obvious question - I need the values on X axis to be spread the entire axis equidistant.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let colour = %str(red|green|blue);

proc sgplot data=final noautolegend;
	vbox aval / category=avisitn datalabel=usubjid boxwidth=1;

	%do i = 1 %to &amp;amp;n.;
		%let col&amp;amp;i = %scan(&amp;amp;colour,&amp;amp;i,'|');
		refline &amp;amp;&amp;amp;minref&amp;amp;i &amp;amp;&amp;amp;maxref&amp;amp;i / axis=y lineattrs=(pattern=shortdash color=&amp;amp;&amp;amp;col&amp;amp;i);
	%end;

	yaxis type=linear values=(&amp;amp;minval. to &amp;amp;maxval. by &amp;amp;byvar.) label=%sysfunc(compbl("&amp;amp;param."));
	xaxis type=linear values=(1 2 3 4 5 6 7) label="Visit";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems there is something obvious that I'm missing here. Any help would be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;D&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="delete_boxplot.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14595i757539A429E41A93/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_boxplot.jpg" alt="delete_boxplot.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 21:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/389993#M13356</guid>
      <dc:creator>kingCobra</dc:creator>
      <dc:date>2017-08-22T21:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390006#M13357</link>
      <description>&lt;P&gt;Downloading of Microsoft Office documents is discouraged, as it is a security risk. So, I can't see the problem.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 19:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390006#M13357</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-22T19:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390012#M13359</link>
      <description>&lt;P&gt;Can't paste the plot here. Don't know how to present the plot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Main problem is - the values on x axis are concentrated near the centre, taking 1/3 of the total space on x axis. So the rest 2/3 are just empty. I want the values to be spread equally on the entire x axis&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 20:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390012#M13359</guid>
      <dc:creator>kingCobra</dc:creator>
      <dc:date>2017-08-22T20:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390013#M13360</link>
      <description>&lt;P&gt;Attach plot as pdf file?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 20:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390013#M13360</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-22T20:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390015#M13361</link>
      <description>&lt;P&gt;Somethings are not matching between the graph and the code you have.provided. &amp;nbsp;You have provided x-axis label of "Visit", but I don't see it on the axis. &amp;nbsp;Also, I assume the AVISITN values are from 1-7, but it it is not cleary what is causing the large offsets on left or right. &amp;nbsp;I suggest try setting xaxis offsetmin=0 offsetmax=0 to see if the axis stretches the full width. &amp;nbsp;If yes, you could put in the right fractional value to get what you want. &amp;nbsp;But, still it is not clear what is causing the offsets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be easier to help if you send a program with built in (sample) data as part of the program. &amp;nbsp;Then we can try running your program. &amp;nbsp;Which SAS release do you have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran this code and it worked for me. &amp;nbsp;I removed&amp;nbsp;DataLabel=usubjid and the macro lines for reference lines. &amp;nbsp;Note I did get the "Visit" label on the x-axis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
  do avisitn=2, 6, 7;
    do j=1 to 100;
	  aval=100+80*ranuni(2);
	  output;
	end;
  end;
run;

proc sgplot data=final noautolegend;
vbox aval / category=avisitn  boxwidth=1  ;
xaxis type=linear values=(1 2 3 4 5 6 7) label="Visit" ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Box1.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14594i7CD48DA3F15640AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Box1.png" alt="Box1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 20:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390015#M13361</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2017-08-22T20:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390018#M13363</link>
      <description>&lt;P&gt;Hi Sanjay,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The label for x-axis and y-axis are not shown on the attached file as I copied the plot from a pdf output onto a MS word doc.&lt;/P&gt;
&lt;P&gt;The AVISITN is from 1-7, yes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without the macro lines for refline &amp;nbsp;and datalabel=usubjid, I'm getting the same plot as you have got.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My guess is the probably the refline statement is causing the problem but can't figure out why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll try the offsetmin and offsetmax as you've suggested. If that doesn't work, I'll put a sample data with my code.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 20:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390018#M13363</guid>
      <dc:creator>kingCobra</dc:creator>
      <dc:date>2017-08-22T20:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390021#M13364</link>
      <description>&lt;P&gt;We can better&amp;nbsp;help debug this if you include the full code, with all the macro variables and sample data so we can run the program to see the results. &amp;nbsp;If you have long usubjid data labels, they will contribute of offsets. &amp;nbsp;But I don't see any data labels either.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 20:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390021#M13364</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2017-08-22T20:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390031#M13365</link>
      <description>&lt;P&gt;Run the code with options MPRINT symbolgen;&lt;/P&gt;
&lt;P&gt;compare the&amp;nbsp;log of the run&amp;nbsp;with the code you have that generated the desired graph &amp;nbsp;before you added any macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you by any chance generate an earlier version of the graph of OFFSETMAX on the XAXIS and not replace the actual output file&amp;nbsp;for some reason such as open in another program to view the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to look at your ODS Graphics options and ODS PDF.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 21:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390031#M13365</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-22T21:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390038#M13369</link>
      <description>I've edited your post - added the code using a code box and formatted it, as well as embedded the image using the PHOTO option. You can attach images with the photo instead of attachments. JPG/PNG are accepted formats among others.</description>
      <pubDate>Tue, 22 Aug 2017 21:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390038#M13369</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-22T21:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390043#M13371</link>
      <description>Thanks</description>
      <pubDate>Tue, 22 Aug 2017 21:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390043#M13371</guid>
      <dc:creator>kingCobra</dc:creator>
      <dc:date>2017-08-22T21:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390226#M13374</link>
      <description>&lt;P&gt;Hi Sanjay,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The offsetmin/max = 0.1 worked. Thanks for that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I'm still unsure why the problem occured at the first place. So I ran my code without those options. Here is my code and output and attached is the data (sample) in pdf.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro labplot(paramcd = , minval = , maxval= , byvar= );

options mprint mlogic;

data adlb;
   set adam.adlb;
   where saffl = "Y" and aval ne . and paramcd = "%qupcase(&amp;amp;paramcd)";
   param = propcase(param);
   keep usubjid avisitn avisit paramcd param trtan aval anrlo anrhi;
run;

proc sort data = adlb out=final;
  by usubjid;
run;

proc sql noprint;
      select param
        into: param
        from final;

      select count(distinct anrlo)
	  into: n
         from final;

      select distinct anrlo
          into: minref1 - : minref%cmpres(&amp;amp;n.)
	  from final;

      select distinct anrhi
          into: maxref1 - : maxref%cmpres(&amp;amp;n.)
	  from final;
quit;

%let colour = %str(red|green|blue);

ods graphics on / reset=all imagefmt=png outputfmt=PNG border=off height=100% width=100% antialias=on imagename="hemoglobin";
   
   proc sgplot data=final noautolegend;
       vbox aval / category=avisitn datalabel=usubjid boxwidth=1;
	%do i = 1 %to &amp;amp;n.;
	     %let col&amp;amp;i = %scan(&amp;amp;colour,&amp;amp;i,'|');
            refline &amp;amp;&amp;amp;minref&amp;amp;i &amp;amp;&amp;amp;maxref&amp;amp;i / axis=y lineattrs=(pattern=shortdash color=&amp;amp;&amp;amp;col&amp;amp;i);
	%end;
      yaxis type=linear values=(&amp;amp;minval. to &amp;amp;maxval. by &amp;amp;byvar.) label=%sysfunc(compbl("&amp;amp;param."));
      xaxis type=linear values=(1 2 3 4 5 6 7) label="Visit" /*offsetmin=0.1 offsetmax=0.1*/;
   run;

ods graphics off;

%mend labplot;

%labplot(paramcd = HGB, minval=100, maxval=180, byvar=10);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hemoglobin.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14612i1AC429EC179B0B4F/image-size/large?v=v2&amp;amp;px=999" role="button" title="hemoglobin.png" alt="hemoglobin.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 13:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390226#M13374</guid>
      <dc:creator>kingCobra</dc:creator>
      <dc:date>2017-08-23T13:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390625#M13384</link>
      <description>&lt;P&gt;If you can send a simple program with built in data (like my example) that shows the problem, you have a better chance to get more help from the community. &amp;nbsp;With a program using macros and data in pdf, it is much harder to help debug the issue.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 14:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/390625#M13384</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2017-08-24T14:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SGplot - formatting X axis</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/391647#M13396</link>
      <description>&lt;P&gt;Without using the macro, I'm getting what I want. It's only when I use the macro, the offset problem occurs. Anyway using offsetmin/max=0.1 solve my problem.&lt;/P&gt;
&lt;P&gt;Thanks for the solution. I'll be mindful about the data while I ask question next time.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 19:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-SGplot-formatting-X-axis/m-p/391647#M13396</guid>
      <dc:creator>kingCobra</dc:creator>
      <dc:date>2017-08-29T19:27:56Z</dc:date>
    </item>
  </channel>
</rss>

