<?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 Format Y Axis with SGSCATTER in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876716#M38939</link>
    <description>&lt;P&gt;I have a report with 5 graphs (all different variables). I used proc scscatter because all graphs need to be on the same page. One problem I am running into is that I want to customize the axes on all of the graphs so that they are more uniform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code created to generate graphs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sgscatter data=ten;&lt;BR /&gt;plot (Hosp_admit_ma PctAdmit7_LF peds_prop icu_prop vent_prop)*date / join markerattrs=(size=1);&lt;BR /&gt;where "&amp;amp;start."d &amp;lt;= date &amp;lt;= "&amp;amp;end."d;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Graphs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="scolitti1_0-1684519051329.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84141i9006B0C06B4E3686/image-size/medium?v=v2&amp;amp;px=400" role="button" title="scolitti1_0-1684519051329.png" alt="scolitti1_0-1684519051329.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2023 17:59:55 GMT</pubDate>
    <dc:creator>scolitti1</dc:creator>
    <dc:date>2023-05-19T17:59:55Z</dc:date>
    <item>
      <title>Format Y Axis with SGSCATTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876716#M38939</link>
      <description>&lt;P&gt;I have a report with 5 graphs (all different variables). I used proc scscatter because all graphs need to be on the same page. One problem I am running into is that I want to customize the axes on all of the graphs so that they are more uniform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code created to generate graphs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sgscatter data=ten;&lt;BR /&gt;plot (Hosp_admit_ma PctAdmit7_LF peds_prop icu_prop vent_prop)*date / join markerattrs=(size=1);&lt;BR /&gt;where "&amp;amp;start."d &amp;lt;= date &amp;lt;= "&amp;amp;end."d;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Graphs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="scolitti1_0-1684519051329.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84141i9006B0C06B4E3686/image-size/medium?v=v2&amp;amp;px=400" role="button" title="scolitti1_0-1684519051329.png" alt="scolitti1_0-1684519051329.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 17:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876716#M38939</guid>
      <dc:creator>scolitti1</dc:creator>
      <dc:date>2023-05-19T17:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Format Y Axis with SGSCATTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876717#M38940</link>
      <description>&lt;P&gt;You need to define what you mean by "more uniform".&lt;/P&gt;
&lt;P&gt;Apparently 4 of your y variables are percentages, which mean underlying values between 0 and 1 (0% to 100 %) and the fifth variable has a much larger range of values, around 40 to 70. So just getting those to be uniform is very problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding UNISCALE=X should make the horizontal axis the same in all plots but you are going to have to make some serious decisions about what to do with the Y values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this really need to be 5 separate plots? I might reshape the data a bit to have a variable that indicates what the percentage values represent and use that variable as a Group variable to overlay them. Then use the count data overlayed in the same plot against a second yaxis.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data reshape;
   set ten;
   array p (*) PctAdmit7_LF peds_prop icu_prop vent_prop;
   do i=1 to dim(p);
      groupvar=vname(p[i]);
      /* could use Vlabel to have the label of the variable
         appear in the legend instead of the name
         but would need to specify a length for the 
         groupvar variable first
      */
      pctvalue= p[i];
      output;
   end;
   keep groupvar pctvalue Hosp_admit_ma date;
run;

proc sgploet data=reshape;
   series x=date y=pctvalue/group=groupvar;
   series x=date y=Hosp_admit_ma/ yaxis2;
run;&lt;/PRE&gt;
&lt;P&gt;You would use Xaxis and Yaxis / Yaxis2 statements to control the appearance of the axis.&lt;/P&gt;
&lt;P&gt;May need to work with KEYLEGEND and some other options to get the legend as desired but worry about that if this is close to useful.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 18:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876717#M38940</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-19T18:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Format Y Axis with SGSCATTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876745#M38943</link>
      <description>&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures/&lt;/A&gt;</description>
      <pubDate>Sat, 20 May 2023 10:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876745#M38943</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-05-20T10:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Format Y Axis with SGSCATTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876936#M38950</link>
      <description>Yes, the issue with only 1 graph not being a percentage makes things more difficult. Unfortunately, my leadership wants each variable to be its own graph. Well maybe if not uniform, is there a way to customize the Y axis using sgscatter?</description>
      <pubDate>Mon, 22 May 2023 18:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876936#M38950</guid>
      <dc:creator>scolitti1</dc:creator>
      <dc:date>2023-05-22T18:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Format Y Axis with SGSCATTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876999#M38953</link>
      <description>&lt;P&gt;Proc SGSCATTER does not allow for axis control of the individual plots. You can use GTL (Graph Template Language) to achieve this. Proc SGSCATTER has the TMPLOUT= option to save the GTL used to create the graph. Adapt this code based on this example&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n0n10xwfn3h4hnn10v5joeerd9m8.htm#p0z5nlcjy9hsnxn1ibiivnshllel" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n0n10xwfn3h4hnn10v5joeerd9m8.htm#p0z5nlcjy9hsnxn1ibiivnshllel&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To give you an idea, here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/n0n10xwfn3h4hnn10v5joeerd9m8.htm#p0z5nlcjy9hsnxn1ibiivnshllel
*/
/* Create the stock data for Microsoft for the years 2001 and 2002 */
data stockyear1 stockyear2;
  set sashelp.stocks(where=(stock eq "Microsoft" and year(date) in (2001 2002)));
  volume = volume/1000000;
  volumePct = volume / 100;
  if year(date) = 2001 then 
    output work.stockyear1;
  else if year(date)=2002 then
    output work.stockyear2;
run;

data msstock;
  merge work.stockyear1(rename=(date=year1date close=year1close volume=year1vol))
    work.stockyear2(rename=(date=year2date close=year2close volume=year2vol volumePct=year2volpct));
  format year1date year2date monname3. year1close year2close dollar6. year2volpct percent9.1 ;
run;

ods path (prepend) work.mytemplates (update);
/* Create the graph template */
proc template;
  define statgraph graphlattice;
    begingraph;
      entrytitle "Microsoft Stock Performance in 2001 and 2002";
      layout lattice / columns=2 columngutter=5 rowgutter=5;
        /* Column headers */
        column2headers;
          entry textattrs=GraphData1(weight=bold size=9pt) "Year 2001";
          entry textattrs=GraphData2(weight=bold size=9pt) "Year 2002";
        endcolumn2headers;

        /* Row 1 content (cells 1-2) */
        layout overlay /
          xaxisopts=(display=(ticks tickvalues) 
            timeopts=(viewmax='01DEC2001'd tickvalueformat=monname3.))
          yaxisopts=(
            label="Closing Price"
            linearopts=(viewmin=30 viewmax=80 tickvaluesequence=(start=30 end=80 increment=10))
          );
          seriesplot x=year1date  y=year1close / display=all smoothconnect=true
            lineattrs=GraphData1 markerattrs=GraphData1;
        endlayout;
        layout overlay /
          xaxisopts=(display=(ticks tickvalues) 
            timeopts=(viewmax='01DEC2002'd tickvalueformat=monname3.))
          yaxisopts=(
            label="Closing Price"
            linearopts=(viewmin=30 viewmax=80 tickvaluesequence=(start=30 end=80 increment=10))
          );
          seriesplot x=year2date  y=year2close / display=all smoothconnect=true
            lineattrs=GraphData2 markerattrs=GraphData2;
        endlayout;

        /* Row 2 content (cells 3-4) */
        layout overlay /
          xaxisopts=(display=(ticks tickvalues) 
            timeopts=(viewmax='01DEC2001'd tickvalueformat=monname3.))
          yaxisopts=(label="Volume (Millions)");
          needleplot x=year1date  y=year1vol / displaybaseline=off
            lineattrs=GraphData1;
        endlayout;
        layout overlay /
          xaxisopts=(display=(ticks tickvalues) 
            timeopts=(viewmax='01DEC2002'd tickvalueformat=monname3.))
          yaxisopts=(
            label="Volume as %"
            linearopts=(viewmin=0 viewmax=1.5 tickvaluesequence=( start=0 end=1.5 increment=0.25))
          );
          seriesplot x=year2date  y=year2volpct / lineattrs=GraphData2;
        endlayout;
      endlayout;
    endgraph;
  end;
run;

proc sgrender data=msstock template=graphlattice;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 06:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Format-Y-Axis-with-SGSCATTER/m-p/876999#M38953</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2023-05-23T06:58:23Z</dc:date>
    </item>
  </channel>
</rss>

