<?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: create a pdf report with graph for multiple tests in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709535#M218205</link>
    <description>&lt;P&gt;I tried this and it worked! The only problem I have is the axes range. Both graphs are showing from 0 to 20, so I am getting two straight lines. I need the axis to be in 0.1 - 0.01 increments or so around its average value to see the shape for each metric.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jan 2021 00:02:08 GMT</pubDate>
    <dc:creator>asasha</dc:creator>
    <dc:date>2021-01-06T00:02:08Z</dc:date>
    <item>
      <title>create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709518#M218198</link>
      <description>&lt;P&gt;I have a table parms that looks like this:&lt;/P&gt;&lt;PRE&gt;parameter split test1 test2 test3... test10
gini      1      
gini      2       
gini      3
mse       1
mse       2
mse       3&lt;/PRE&gt;&lt;P&gt;I need to create a macro that would take this table and create a pdf report of 3 pages (a page for each split), each page containing 2 graphs (gini &amp;amp; mse), each graph plotting the values of the tests (10 points). Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 22:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709518#M218198</guid>
      <dc:creator>asasha</dc:creator>
      <dc:date>2021-01-05T22:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709519#M218199</link>
      <description>&lt;P&gt;Before you convert code to a macro you need working code, do you have code that creates the report you'd like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend first doing that. I suspect it'll be easier if you restructure your data as well, to a long format. You can use PROC TRANSPOSE for that.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Transposing data tutorials:&lt;/STRONG&gt;&lt;BR /&gt;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank" rel="noopener"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank" rel="noopener"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Then create your base report which would be pretty straightforward IME.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not exactly sure what the macro part would be since all the data is represented in a report, you could probably just repeat it three times much faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=have;
where parameter="gini" and split="1";
series x= testNumber y = testValue;
run;

proc sgplot data=have;
where parameter="mse" and split="1";
series x= testNumber y = testValue;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are some macro references to get you started if you really want a macro for some reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank" rel="noopener"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank" rel="noopener"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Examples of common macro usage&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338636"&gt;@asasha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a table parms that looks like this:&lt;/P&gt;
&lt;PRE&gt;parameter split test1 test2 test3... test10
gini      1      
gini      2       
gini      3
mse       1
mse       2
mse       3&lt;/PRE&gt;
&lt;P&gt;I need to create a macro that would take this table and create a pdf report of 3 pages (a page for each split), each page containing 2 graphs (gini &amp;amp; mse), each graph plotting the values of the tests (10 points). Thank you for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 22:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709519#M218199</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-01-05T22:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709521#M218201</link>
      <description>&lt;P&gt;Actual data would help.&lt;/P&gt;
&lt;P&gt;The SAS graphing procedure will work a lot better with data in the form of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Parameter&amp;nbsp; split test_number&amp;nbsp; test_value&lt;/P&gt;
&lt;P&gt;gini&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;
&lt;P&gt;gini&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 128&lt;/P&gt;
&lt;P&gt;gini&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 121&lt;/P&gt;
&lt;P&gt;and so forth.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc transpose can help get it in that form.&lt;/P&gt;
&lt;P&gt;Proc SGPANEL will make a separate graph for each level of a BY variable, such as Split and&lt;/P&gt;
&lt;P&gt;separate panels for values of Parameter on a Panelby statement.&lt;/P&gt;
&lt;P&gt;Why type of plot do you want? Scatter, series, bar, needle, regression? Is the test number supposed to be the xaxis value?&lt;/P&gt;
&lt;P&gt;Do you want the two parameter graphs side-by-side , one above the other, or possibly superimposed (both in one graph with two colors to differentiate the parameter)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 22:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709521#M218201</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-05T22:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709522#M218202</link>
      <description>&lt;P&gt;I would like a simple line graph. The test numbers would be the x axis. Two separate graphs are good (i.e. one above the other). I have no SAS experience. Transpose makes sense! I need it to be a macro that creates one report, as the number of tests could be more (i.e. 50) and the number of splits could be more as well. Each page would represent one split and contain both graphs.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 22:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709522#M218202</guid>
      <dc:creator>asasha</dc:creator>
      <dc:date>2021-01-05T22:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709528#M218203</link>
      <description>Then after you transpose the data, try the code I've posted. It should generate the line graphs that you want and then you can fuss about with the size and styling to get it perfected. Once you have that done, then you can create a macro to loop through the splits or use CALL EXECUTE(recommended) to run it once for each split as per the tutorial in my first post.</description>
      <pubDate>Tue, 05 Jan 2021 23:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709528#M218203</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-01-05T23:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709532#M218204</link>
      <description>&lt;P&gt;Likely no macro needed.&lt;/P&gt;
&lt;P&gt;You should be able to copy and run this code:&lt;/P&gt;
&lt;PRE&gt;data have;
   do parameter='gini','mse';
      do split=1 to 3;
      array test{10};
         do i=1 to dim(test);
            test[i] = 100*rand('uniform');
         end;
         output;
      end;
   end;
run;


proc sort data=have;
   by split parameter;
run;

proc transpose data=have
   out=trans;
   by split parameter;
   var test: ;/* the : immediately after the test
               tells SAS to use all variables starting
               with "test"*/
run;
data forplot;
   set trans;
   Testnumber = input(substr(_name_,5),best.);
run;

proc sgpanel data=forplot;
  by split;
  panelby parameter /rows=2;
  series x=testnumber y=col1;
run;

/* or */
proc sgplot data=forplot;
  by split;
  series x=testnumber y=col1 / group=parameter;
run;&lt;/PRE&gt;
&lt;P&gt;The first data step just makes a data set with some values. Since the test variable values are random the likely do not look like your data.&lt;/P&gt;
&lt;P&gt;Sort to get order needed to Transpose.&lt;/P&gt;
&lt;P&gt;Then transpose the data.&lt;/P&gt;
&lt;P&gt;If your data doesn't have any surprises, like duplicate Parameter/split pairs of values the data will have one output variable named Col1 with the values of the test numbers.&lt;/P&gt;
&lt;P&gt;The second data step is to get the test number as a numeric value. Not needed but easier to control axis values with numbers than text if needed.&lt;/P&gt;
&lt;P&gt;Then two different approaches to plotting the data as series.&lt;/P&gt;
&lt;P&gt;Note, if the input data set has different numbers of tests it still works (change the size of the TEST array in the first data set, splits change the split = 1 to &amp;lt;some other integer&amp;gt;, or parameter, add other parameters in the list quoted and separated by commas. Warning: if you add parameters for testing the LONGEST name needs to be the first one in the list because of the way SAS creates text variables if you do not declare them with a LENGTH statement prior to the first use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To create a PDF of the results the graph code would be placed in an "ods destination sandwich". That is a statement that tells say to start sending data to a file of the specified type and to stop surrounding the output. that generically would look like:&lt;/P&gt;
&lt;PRE&gt;ods pdf file="C:\folder\otherfolder\filenameyouwant.pdf";

&amp;lt;any SAS procedures that create output, Proc Print,
the graph procedure, other procedures &amp;gt;

ods pdf close;  /* stop sending output to the pdf file*/&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2021 23:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709532#M218204</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-05T23:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709535#M218205</link>
      <description>&lt;P&gt;I tried this and it worked! The only problem I have is the axes range. Both graphs are showing from 0 to 20, so I am getting two straight lines. I need the axis to be in 0.1 - 0.01 increments or so around its average value to see the shape for each metric.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 00:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709535#M218205</guid>
      <dc:creator>asasha</dc:creator>
      <dc:date>2021-01-06T00:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709536#M218206</link>
      <description>&lt;P&gt;You can control the displayed axis ranges by using a values statement.&lt;/P&gt;
&lt;P&gt;You didn't mention the actual needed range but&lt;/P&gt;
&lt;P&gt;rowaxis values =( 0 to 1 by 0.1)&lt;/P&gt;
&lt;P&gt;would create 0, 0.1, 0.2 ... 1 axis tick marks on the vertical axis.&lt;/P&gt;
&lt;P&gt;If you need to have different ranges for the yaxis you might try UNISCALE=Column in the PANELBY statement. That will allow rows to have different scales but you would not want to use the Values in a rowaxis statement. The rowaxis would set the axis for each row to the specified list. It isn't quite clear which you may need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally SAS is pretty good about guesstimating ranges. I would expect one of the values to have a range close to 20, may be above 16.&lt;/P&gt;
&lt;P&gt;If you really need to control lots of axis values then that is going to run a lot more programming&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 00:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709536#M218206</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-06T00:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: create a pdf report with graph for multiple tests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709538#M218207</link>
      <description>&lt;P&gt;Uniscale did the trick, thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 00:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-pdf-report-with-graph-for-multiple-tests/m-p/709538#M218207</guid>
      <dc:creator>asasha</dc:creator>
      <dc:date>2021-01-06T00:20:23Z</dc:date>
    </item>
  </channel>
</rss>

