<?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: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749976#M21682</link>
    <description>Thanks for the mention, Rick! It is good to see the ODS document plugged. It is an incredibly useful tool. If you have ever used SAS documentation from any of the products from the advanced analytics group (e.g. STAT, QC, IML, OR, ETS, Enterprise Miner, and so on) you have seen the results of using the ODS document behinds the scenes. SAS is run, output is captured, then output, often subsets of the full output, are replayed into portions of the documentation. Many years ago, output was captured manually and there was no guarantee it was current. For many years now, thanks in part to tools that rely on the ODS document, you can be sure that the output is correct and current.</description>
    <pubDate>Wed, 23 Jun 2021 19:25:55 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2021-06-23T19:25:55Z</dc:date>
    <item>
      <title>ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749836#M21679</link>
      <description>&lt;P&gt;I can create an output with four plots on one page using ODS LAYOUT ABSOLUTE, as shown in code #1. But then I want to use a BY statement in PROC SGPLOT, such that the first I get four plots on one page, where all four plots are for the same level of the BY variable and the plots are always in the same position, see code #2.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Code #1, this works as expected, but I have not used a BY statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods pdf file="absolute.pdf";
ods layout absolute ;
ods region x=.5in y=0.1in width=4in height=2.75in;
proc sgplot data=sashelp.cars;
    histogram msrp;
run;
ods region  x=5.1in y=.1in width=4in height=2.75in;
proc sgplot data=sashelp.cars;
    histogram invoice;
run;
ods region  x=.5in y=5.25in width=4in height=2.75in;
proc sgplot data=sashelp.cars;
    histogram mpg_city;
run;
ods region  x=5.1in y=5.25in width=4in height=2.75in;
proc sgplot data=sashelp.cars;
    histogram horsepower;
run;
ods layout end;
ods pdf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, code #2, with a BY Statement, it doesn't work at all, how can I get something like this to work? I want three output pages, the first page would be four plots for origin='Asia', with MSRP top left, INVOICE top right, MPG_CITY bottom left and HORSEPOWER bottom right; second page would be for origin='Europe', exact same arrangement of plots; third page would be for origin='USA', exact same arrangement of plots.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
    by origin;
run;
ods pdf file="absolute2.pdf";
ods layout absolute ;
ods region x=.5in y=0.1in width=4in height=2.75in;
proc sgplot data=cars;
    by origin;
    histogram msrp;
run;
ods region  x=5.1in y=.1in width=4in height=2.75in;
proc sgplot data=cars;
    by origin;
    histogram invoice;
run;
ods region  x=.5in y=5.25in width=4in height=2.75in;
proc sgplot data=cars;
    by origin;
    histogram mpg_city;
run;
ods region  x=5.1in y=5.25in width=4in height=2.75in;
proc sgplot data=cars;
    by origin;
    histogram horsepower;
run;
ods layout end;
ods pdf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Adding: I'm sure I could just wrap this in a macro and loop through all possible values of the BY variable and do it that way, but over the years I have found that SAS is very good at anticipating needs and creating features to do this, so really I'd like to do this without a macro if possible.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 12:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749836#M21679</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-23T12:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749940#M21680</link>
      <description>&lt;P&gt;A macro is not bad, but (as requested) here is an alternative that uses a SAS feature: replaying output in a different order by using PROC DOCUMENT.&amp;nbsp; Do the following:&lt;/P&gt;
&lt;P&gt;1. Read the article &lt;A href="https://blogs.sas.com/content/iml/2017/03/06/reorder-output-group-analysis-sas.html" target="_self"&gt;"Reorder the output from a BY-group analysis in SAS",&lt;/A&gt;&amp;nbsp;which shows how to use ODS DOCUMENT to save your output to a document.&lt;/P&gt;
&lt;P&gt;2. Use the second part of your program to write the graphs. (You can omit the ODS LAYOUT statements)&lt;/P&gt;
&lt;P&gt;3. Use ODS LAYOUT and PROC DOCUMENT to replay the graphs in the order you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't used ODS LAYOUT ABSOLUTE before and I am not skilled with PDF output, but the following (which uses ODS LAYOUT GRIDDED to HTML) should get you started and demonstrate the technique:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
    by origin;
run;
/* write all output to a document */
ods document name=doc(write);      /* wrap ODS DOCUMENT around the output */
proc sgplot data=cars;
    by origin;
    histogram msrp;
run;
proc sgplot data=cars;
    by origin;
    histogram invoice;
run;
proc sgplot data=cars;
    by origin;
    histogram mpg_city;
run;
proc sgplot data=cars;
    by origin;
    histogram horsepower;
run;
ods document close;                /* wrap ODS DOCUMENT around the output */

/* list the outputs */
proc document name=doc(read);
   list / levels=all bygroups;  /* add column for each BY group var */
run;


/* Replay the graphs in a different order */
ods layout gridded rows=2 columns=2 advance=table
    row_gutter=10px column_gutter=10px
    x=.5in y=0.1in width=4in height=2.75in;
proc document name=doc(read);
      replay \SGPlot#1\ByGroup1#1\SGPlot#1;   /* Asia : MSRP */
      replay \SGPlot#2\ByGroup1#1\SGPlot#1;   /* Asia : Invoice */
      replay \SGPlot#3\ByGroup1#1\SGPlot#1;   /* Asia : MPG_City */
      replay \SGPlot#4\ByGroup1#1\SGPlot#1;   /* Asia : Horesepower */
run;quit;
ods layout end;

ods layout gridded rows=2 columns=2 advance=table
    row_gutter=10px column_gutter=10px
    x=.5in y=0.1in width=4in height=2.75in;
proc document name=doc(read);
      replay \SGPlot#1\ByGroup2#1\SGPlot#1;   /* Europe : MSRP */
      replay \SGPlot#2\ByGroup2#1\SGPlot#1;   /* Europe : Invoice */
      replay \SGPlot#3\ByGroup2#1\SGPlot#1;   /* Europe : MPG_City */
      replay \SGPlot#4\ByGroup2#1\SGPlot#1;   /* Europe : Horesepower */
run; quit;
ods layout end;

ods layout gridded rows=2 columns=2 advance=table
    row_gutter=10px column_gutter=10px
    x=.5in y=0.1in width=4in height=2.75in;
proc document name=doc(read);
   replay \SGPlot#1\ByGroup3#1\SGPlot#1;   /* USA : MSRP */
   replay \SGPlot#2\ByGroup3#1\SGPlot#1;   /* USA : Invoice */
   replay \SGPlot#3\ByGroup3#1\SGPlot#1;   /* USA : MPG_City */
   replay \SGPlot#4\ByGroup3#1\SGPlot#1;   /* USA : Horesepower */
run; quit;
ods layout end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't want to type out all those statements, you can use a DATA _NULL_ step and CALL EXECUTE to automate this process, as shown in &lt;A href="https://blogs.sas.com/content/iml/2017/03/08/conditional-output-proc-document.html" target="_self"&gt;"Display output conditionally with PROC DOCUMENT."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A hat tip to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;&amp;nbsp;who taught me this technique.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 18:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749940#M21680</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-06-23T18:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749973#M21681</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;, I will give it a try and report back ... but it does seem like a macro would be useful here too, especially if I have a lot more groups of the BY variable.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 19:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749973#M21681</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-23T19:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749976#M21682</link>
      <description>Thanks for the mention, Rick! It is good to see the ODS document plugged. It is an incredibly useful tool. If you have ever used SAS documentation from any of the products from the advanced analytics group (e.g. STAT, QC, IML, OR, ETS, Enterprise Miner, and so on) you have seen the results of using the ODS document behinds the scenes. SAS is run, output is captured, then output, often subsets of the full output, are replayed into portions of the documentation. Many years ago, output was captured manually and there was no guarantee it was current. For many years now, thanks in part to tools that rely on the ODS document, you can be sure that the output is correct and current.</description>
      <pubDate>Wed, 23 Jun 2021 19:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749976#M21682</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2021-06-23T19:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749987#M21683</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Can you explain this line? Why does SGPlot#1 appear twice? In particular, what does the second SGPlot#1 indicate? Where can I find this in the docs?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;replay \SGPlot#1\ByGroup3#1\SGPlot#1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 19:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749987#M21683</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-23T19:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749989#M21684</link>
      <description>&lt;P&gt;\ProcName\ByGroup\ODSName&lt;/P&gt;
&lt;P&gt;This is a version of the familiar PATH that you see when you use ODS TRACE. See&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/statug/statug_ods_overview13.htm" target="_blank"&gt;SAS Help Center: Paths and Selection&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;ODS TRACE ON;&lt;/P&gt;
&lt;P&gt;prior to writing to the document to see "human readable" versions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/749989#M21684</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-06-23T20:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/750018#M21685</link>
      <description>&lt;P&gt;The heuristic I always use is list the contents of the document, and then use *precisely* the names that the document says are there. I never try to understand or predict them, although before I retired, I could see the logic.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:37:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/750018#M21685</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2021-06-23T20:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/750022#M21686</link>
      <description>I should add that the path is hierarchical with # numbers that identify the sequence so that every object in the document has a unique path.</description>
      <pubDate>Wed, 23 Jun 2021 20:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/750022#M21686</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2021-06-23T20:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: ODS LAYOUT ABSOLUTE with a BY statement in PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/750143#M21690</link>
      <description>&lt;P&gt;Once I wrote the output of the PROC DOCUMENT to a data set so I could look at it, it all became very clear to me. Either a macro or CALL EXECUTE based on the data set output from PROC DOCUMENT would get the job done.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 10:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/ODS-LAYOUT-ABSOLUTE-with-a-BY-statement-in-PROC-SGPLOT/m-p/750143#M21690</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-24T10:50:03Z</dc:date>
    </item>
  </channel>
</rss>

