<?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 report without hardcoding variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613340#M179107</link>
    <description>&lt;P&gt;Consider&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input Mgr $ Exception $ CNT ;
datalines;
Smith Transfer 1
Smith Transfer 1
Smith Cancel 1
Brown Reinstate 1
Brown Terminate 1
Saunders Transfer 1
Saunders Cancel 1
;
run;
proc report data=have     ;
   column Exception Mgr, cnt ;
   define Exception / group style (column)=[cellwidth=100pt] "EXC TYPE";
   Define mgr/ across;

   define cnt / sum "Total" style(column)=[cellwidth=90pt];
   rbreak after / summarize style (summary)= Header; 
   compute after;
      Exception = 'Total';
   endcomp;
run;
&lt;/PRE&gt;
&lt;P&gt;The comma between mgr and cnt on the columns statement says to "nest" the value or statistic for CNT with the value of MGR.&lt;/P&gt;
&lt;P&gt;And the across define for mgr makes the columns based on the values of the MGR variable.&lt;/P&gt;
&lt;P&gt;May want to suppress the labels for MGR and possibly CNT though.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Dec 2019 20:29:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-12-20T20:29:16Z</dc:date>
    <item>
      <title>Proc report without hardcoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613320#M179105</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Mgr $ Exception $ CNT ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Smith Transfer 1&lt;/P&gt;
&lt;P&gt;Smith Transfer 1&lt;/P&gt;
&lt;P&gt;Smith Cancel 1&lt;/P&gt;
&lt;P&gt;Brown Reinstate 1&lt;/P&gt;
&lt;P&gt;Brown Terminate 1&lt;/P&gt;
&lt;P&gt;Saunders Transfer 1&lt;/P&gt;
&lt;P&gt;Saunders Cancel 1&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=have1;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; exception;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= have1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=have2 (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= _NAME_ _LABEL_) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;let&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;prefix&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=mgr_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;id&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Mgr; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Exception; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; cnt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I want to do a proc report.&amp;nbsp; However the Mgr may expand to more than 3 (currently Smith,Brown and Saunders) or it may contract. Currently I would need to hard-code each Mgr in the proc report.&amp;nbsp; Is there a way to dynamically&amp;nbsp;display the Mgr side by side and account for changes dynamically ??&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;report&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=have1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;wrap&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;style&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(column)={just=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;center&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;};&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;title&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Summary'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;column&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Exception Mgr cnt ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;define&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Exception / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;style&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (column)=[cellwidth=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;pt] &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"EXC TYPE"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Define ???MGR????&lt;/P&gt;
&lt;P&gt;/*define /group style(column)=[cellwidth=100pt] "MANAGER";*/&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;define&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; cnt / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;sum&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"Total"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;style&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(column)=[cellwidth=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;90&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;pt];&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;rbreak&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;after&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;summarize&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;style&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (summary)= Header; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;compute&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;after&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Exception = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Total'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;endcomp&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;title&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;title2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 20:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613320#M179105</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2019-12-20T20:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report without hardcoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613323#M179106</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&lt;BR /&gt;I think you don’t need to transpose your data.&lt;BR /&gt;You can use the raw data directly.&lt;BR /&gt;As you’ve define the variable exception as the ´group‘ variable in the proc report, you can define the variable Mgr as the ‘across’ variable.</description>
      <pubDate>Fri, 20 Dec 2019 20:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613323#M179106</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-20T20:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report without hardcoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613340#M179107</link>
      <description>&lt;P&gt;Consider&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input Mgr $ Exception $ CNT ;
datalines;
Smith Transfer 1
Smith Transfer 1
Smith Cancel 1
Brown Reinstate 1
Brown Terminate 1
Saunders Transfer 1
Saunders Cancel 1
;
run;
proc report data=have     ;
   column Exception Mgr, cnt ;
   define Exception / group style (column)=[cellwidth=100pt] "EXC TYPE";
   Define mgr/ across;

   define cnt / sum "Total" style(column)=[cellwidth=90pt];
   rbreak after / summarize style (summary)= Header; 
   compute after;
      Exception = 'Total';
   endcomp;
run;
&lt;/PRE&gt;
&lt;P&gt;The comma between mgr and cnt on the columns statement says to "nest" the value or statistic for CNT with the value of MGR.&lt;/P&gt;
&lt;P&gt;And the across define for mgr makes the columns based on the values of the MGR variable.&lt;/P&gt;
&lt;P&gt;May want to suppress the labels for MGR and possibly CNT though.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 20:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-without-hardcoding-variables/m-p/613340#M179107</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-20T20:29:16Z</dc:date>
    </item>
  </channel>
</rss>

