<?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 YAXIS moving around depending on values in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643402#M19806</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a series of plots using sgplot.&amp;nbsp; The values on the y-axis vary.&amp;nbsp; For some, the values only have 1 digits (e.g. 1 to 8).&amp;nbsp; For others, there's a decimal place (e.g. 0 to 0.5).&amp;nbsp; For others, there's 3 digits (e.g. 0 to 300).&amp;nbsp; Because of the different amount of space needed to fit these values, my y-axis keeps moving around.&amp;nbsp; It's furthest to the left for those with 1 digit and starts migrating rightwards the more space the values need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would like to freeze the y-axis in one place for all graphs.&amp;nbsp; E.g. Fix the y axis to be some distance from the left of the graphic, unmoving from page to page, regardless of what values are being displayed.&amp;nbsp; Even if space for only 1 digit is needed, we'd like the yaxis to be moved over to accomodate space for 3.&amp;nbsp; Is there anyway to do this?&amp;nbsp; The closest I have come is setting valuesFormat = z5.1 for each graph.&amp;nbsp; Of course, the issue with that is that now I have leading zeros I don't want and a decimal place on graphs that don't need a decimal place.&amp;nbsp; Is there way to tell SAS to draw the yaxis at 10% of the graphing space regardless of values or something similar?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm regards,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 19:20:44 GMT</pubDate>
    <dc:creator>Kastchei</dc:creator>
    <dc:date>2020-04-27T19:20:44Z</dc:date>
    <item>
      <title>YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643402#M19806</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a series of plots using sgplot.&amp;nbsp; The values on the y-axis vary.&amp;nbsp; For some, the values only have 1 digits (e.g. 1 to 8).&amp;nbsp; For others, there's a decimal place (e.g. 0 to 0.5).&amp;nbsp; For others, there's 3 digits (e.g. 0 to 300).&amp;nbsp; Because of the different amount of space needed to fit these values, my y-axis keeps moving around.&amp;nbsp; It's furthest to the left for those with 1 digit and starts migrating rightwards the more space the values need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would like to freeze the y-axis in one place for all graphs.&amp;nbsp; E.g. Fix the y axis to be some distance from the left of the graphic, unmoving from page to page, regardless of what values are being displayed.&amp;nbsp; Even if space for only 1 digit is needed, we'd like the yaxis to be moved over to accomodate space for 3.&amp;nbsp; Is there anyway to do this?&amp;nbsp; The closest I have come is setting valuesFormat = z5.1 for each graph.&amp;nbsp; Of course, the issue with that is that now I have leading zeros I don't want and a decimal place on graphs that don't need a decimal place.&amp;nbsp; Is there way to tell SAS to draw the yaxis at 10% of the graphing space regardless of values or something similar?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm regards,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 19:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643402#M19806</guid>
      <dc:creator>Kastchei</dc:creator>
      <dc:date>2020-04-27T19:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643404#M19807</link>
      <description>&lt;P&gt;Please show the code you are using now.&lt;/P&gt;
&lt;P&gt;Likely you need to provide a YAXIS statement with a VALUES option to show the range of values to display.&lt;/P&gt;
&lt;P&gt;It would help if you tell us the actual range of values you want included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you say "series of plots" using SGPLOT it may be that SGPANEL would be an appropriate choice as well. You can get a separate graph for each level of a variable with the PANELBY statement. By default all of the graphs generated would have the same x and y axis.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 19:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643404#M19807</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-27T19:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643408#M19808</link>
      <description>&lt;P&gt;Sure.&amp;nbsp; Here's the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro plotMedian(title = , test = , yAxisValues = , Units = );
    title font = 'Times New Roman' height = 11pt bold &amp;amp;title ' (' &amp;amp;units ')';
    proc sgplot data = Section_8_30_YForSampleSizeAdded (where = (strip(upCase(test)) = strip(upCase(&amp;amp;test))));
        band x = Window_Label lower = P05 upper = P10 / name = 'P05_P10' transparency = 0.8 fillAttrs = (color = cx79AFE7) legendLabel = '5th-95th Percentiles';
        band x = Window_Label lower = P10 upper = Q1  / name = 'P10_Q1'  transparency = 0.5 fillAttrs = (color = cx79AFE7) legendLabel = '10th-90th Percentiles';
        band x = Window_Label lower = Q1  upper = Q3  / name =  'Q1_Q3'  transparency = 0.5 fillAttrs = (color = cxFFCFA4) legendlabel = '25th-75th Percentiles';
        band x = Window_Label lower = Q3  upper = P90 / name =  'Q3_P90' transparency = 0.5 fillAttrs = (color = cx79AFE7);
        band x = Window_Label lower = P90 upper = P95 / name = 'P90_P95' transparency = 0.8 fillAttrs = (color = cx79AFE7);

        series x = Window_Label y = Mean   / name = 'Mean'   lineAttrs = (pattern = dash  color = purple) legendLabel = 'Mean';
        series x = Window_Label y = Median / name = 'Median' lineAttrs = (pattern = solid color = blue)   legendLabel = 'Median';

        scatter x = Window_Label y = y / markerChar = n markerCharAttrs = (family = 'Times New Roman' size = 10pt);

        yaxis offSetMin = 0.045 offSetMax = 0.00 grid label   = &amp;amp;Units    labelAttrs = (family = 'Times New Roman' size = 10pt weight = bold) values = &amp;amp;yAxisValues /*valuesFormat = yaxis.*/;
        xaxis offSetMin = 0.03  offSetMax = 0.03 grid display = (noLabel) valueAttrs = (family = 'Times New Roman' size = 10pt              ) fitPolicy = rotate
              values = ('Jul 2002 – Dec 2003'  'Jul 2003 – Dec 2004'  'Jul 2004 – Dec 2005'  'Jul 2005 – Dec 2006'
                        'Jul 2006 – Dec 2007'  'Jul 2007 – Dec 2008'  'Jul 2008 – Dec 2009'  'Jul 2009 – Dec 2010'
                        'Jul 2010 – Dec 2011'  'Jul 2011 – Dec 2012'  'Jul 2012 – Dec 2013'  'Jul 2013 – Dec 2014'
                        'Jul 2014 – Dec 2015'  'Jul 2015 – Dec 2016'  'Jul 2016 – Dec 2017'  'Jul 2017 – Dec 2018'
                        'Jul 2018 – Dec 2019');  * These must be listed, because HDL and LDL have no results before 2011. *;

        keylegend 'Median' 'Mean' 'Q1_Q3' 'P10_Q1' 'P05_P10' / position = bottom valueAttrs = (family = 'Times New Roman' size = 10pt);

        format n comma.;
    run;
    title;
%mEnd plotMedian;

ods rtf file = "&amp;amp;outFolder\8. Clinical Chemistry\Clinical Chemistry Lab Plots Median with Percentiles and Mean.doc" startPage = no image_dpi = 600;
ods escapeChar = '`';
    %plotMedian(title = 'Alanine aminotransferase (ALT)'  , test = 'ALT'            , yAxisValues = (0 to  80 by  5  ), Units = 'U/L'     );
    %plotMedian(title = 'Aspartate aminotransferase (AST)', test = 'AST'            , yAxisValues = (0 to  80 by  5  ), Units = 'U/L'     );
    %plotMedian(title = 'Cholesterol: Total'              , test = 'Cholesterol'    , yAxisValues = (0 to 300 by 20  ), Units = 'mg/dL'   );
    %plotMedian(title = 'Cholesterol: HDL'                , test = 'HDL cholesterol', yAxisValues = (0 to 300 by 20  ), Units = 'mg/dL'   );
    %plotMedian(title = 'Cholesterol: LDL'                , test = 'LDL cholesterol', yAxisValues = (0 to 300 by 20  ), Units = 'mg/dL'   );
    %plotMedian(title = 'Creatinine'                      , test = 'Creatinine'     , yAxisValues = (0 to   2 by  0.2), Units = 'mg/dL'   );
    %plotMedian(title = 'Eosinophils, %'                  , test = 'Eosinophil %'   , yAxisValues = (0 to   8 by  1  ), Units = '%'       );
    %plotMedian(title = 'Glucose'                         , test = 'Glucose'        , yAxisValues = (0 to 200 by 20  ), Units = 'mg/dL'   );
    %plotMedian(title = 'Hemoglobin'                      , test = 'Hemoglobin'     , yAxisValues = (0 to  20 by  2  ), Units = 'g/dL'    );
    %plotMedian(title = 'White Blood Cell (WBC) Count'    , test = 'WBC Count'      , yAxisValues = (0 to  12 by  1  ), Units = '·10^3/µL');
ods rtf close;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2020 19:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643408#M19808</guid>
      <dc:creator>Kastchei</dc:creator>
      <dc:date>2020-04-27T19:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643410#M19809</link>
      <description>&lt;P&gt;It appears that your axis moving around is because each call to your macro has a different value for the yaxisvalues.&lt;/P&gt;
&lt;P&gt;Any graphs that you want to display with the same yaxsis appearance will require having the same yaxisvalues set in your macro as you are currently coding things.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 19:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643410#M19809</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-27T19:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643421#M19810</link>
      <description>&lt;P&gt;Thanks for the help.&amp;nbsp; Yes, you are correct.&amp;nbsp; It's moving around because there is a different amount of space needed for each graph depending on the yaxis values.&amp;nbsp; I'm looking for a way to override this and specify exactly where I want the yaxis, regardless of what values are displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g. if the graph is 6 inches wide, I would like to specify that the yaxis always be drawn 1 inch from the left edge.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 20:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643421#M19810</guid>
      <dc:creator>Kastchei</dc:creator>
      <dc:date>2020-04-27T20:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643455#M19811</link>
      <description>&lt;P&gt;I think one way to do this is to use SGPANEL procedure with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PANELBY test / LAYOUT=ROWLATTICE ROWS=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One column of cells will be created, with each cell containing the graph per "test".&amp;nbsp; SGPANEL will automatically align the offset of all the y axes in each cell the the maximum needed for all cells.&amp;nbsp; Setting ROWS=1 will output one cell of the column per output image.&amp;nbsp; Other customizations may be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have a way to test this out, maybe&amp;nbsp;DanH_SAS can verify.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 02:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643455#M19811</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2020-04-28T02:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643565#M19813</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13856"&gt;@Jay54&lt;/a&gt;&amp;nbsp;'s trick will work great, with the addition of a couple of options:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PANELBY test / LAYOUT=ROWLATTICE ROWS=1 UNISCALE=COLUMN NOHEADER;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This big issue with using SGPANEL here is your dynamic title. It is possible to&amp;nbsp;&lt;/SPAN&gt;incorporate your title into your data and doing something like this:&lt;/P&gt;
&lt;P&gt;PANELBY title / ROWS=1 COLUMNS=1&amp;nbsp;&lt;SPAN&gt;UNISCALE=COLUMN;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This would put the title in the cell header for each plot.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 12:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643565#M19813</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2020-04-28T12:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643596#M19814</link>
      <description>&lt;P&gt;For title, you could remove the header (NOHEADER), and add the title using the TEXT plot statement.&amp;nbsp; Add the title to a column in the data called 'Title'.&amp;nbsp; For each value of 'Test', populate this title column with the title, for other obs of same test value, leave it blank.&amp;nbsp; Add two columns xTitle=(mid value of the x range) and yTitle =max value for each test case.&amp;nbsp; Then, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; TEXT x=xTitle y=yTitle text=Title / Position=TOP;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will place the title inside each graph in the center at the top.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 13:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643596#M19814</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2020-04-28T13:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: YAXIS moving around depending on values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643627#M19815</link>
      <description>Thanks for the idea!  I will try it today or tomorrow and let you know how it goes.</description>
      <pubDate>Tue, 28 Apr 2020 14:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/YAXIS-moving-around-depending-on-values/m-p/643627#M19815</guid>
      <dc:creator>Kastchei</dc:creator>
      <dc:date>2020-04-28T14:52:52Z</dc:date>
    </item>
  </channel>
</rss>

