<?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 Proc Tabulate limitation of output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692626#M211022</link>
    <description>&lt;P&gt;I have this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; stock2;&lt;/P&gt;&lt;P&gt;set sashelp.stocks;&lt;/P&gt;&lt;P&gt;year = year(date);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;tabulate&lt;/STRONG&gt; data=stock2;&lt;/P&gt;&lt;P&gt;var Close;&lt;/P&gt;&lt;P&gt;class year Stock;&lt;/P&gt;&lt;P&gt;table year all,stock*close=' '*mean;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe my output is average stock price per year, with an overall average for the entire dataset.&amp;nbsp; Is there a way to reduce this output (say everything since the year 2000), but maintain the average stock price from the entire data set?&amp;nbsp; Like an "if" statement (if year &amp;lt;2000 then delete)?&amp;nbsp; Or something that limits the display of the output to just those months - but maintains the calculation for the entire data?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2020 17:17:47 GMT</pubDate>
    <dc:creator>Lost_Gary</dc:creator>
    <dc:date>2020-10-19T17:17:47Z</dc:date>
    <item>
      <title>Proc Tabulate limitation of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692626#M211022</link>
      <description>&lt;P&gt;I have this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; stock2;&lt;/P&gt;&lt;P&gt;set sashelp.stocks;&lt;/P&gt;&lt;P&gt;year = year(date);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;tabulate&lt;/STRONG&gt; data=stock2;&lt;/P&gt;&lt;P&gt;var Close;&lt;/P&gt;&lt;P&gt;class year Stock;&lt;/P&gt;&lt;P&gt;table year all,stock*close=' '*mean;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe my output is average stock price per year, with an overall average for the entire dataset.&amp;nbsp; Is there a way to reduce this output (say everything since the year 2000), but maintain the average stock price from the entire data set?&amp;nbsp; Like an "if" statement (if year &amp;lt;2000 then delete)?&amp;nbsp; Or something that limits the display of the output to just those months - but maintains the calculation for the entire data?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 17:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692626#M211022</guid>
      <dc:creator>Lost_Gary</dc:creator>
      <dc:date>2020-10-19T17:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate limitation of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692641#M211030</link>
      <description>&lt;P&gt;Presummarize using Proc summary and then play some games with _type_ of the resulting data set.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 17:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692641#M211030</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-19T17:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate limitation of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692653#M211035</link>
      <description>&lt;P&gt;You can do this using a custom multilabel format.&amp;nbsp; 'All' is somewhat misleading to a typical consumer of such reports, so you should modify the label or have a disclaimer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;ods html file='stocks.html' style=plateau;

proc format;
  value mlyear(multilabel)
    '01jan2000'd-'31dec2005'd = [year.]
    low-high = 'All'
  ;
run;

proc tabulate data=sashelp.stocks;
title 'Various stocks averages prices';
var Close;
class date stock;
table date all,stock*close=' '*mean;
format date year.;
run;

proc tabulate data=sashelp.stocks;
title2 'All includes data from years not shown';
var Close;
class date / mlf;
class stock;
table date,stock*close=' '*mean;
format date mlyear.;
run;

ods html close;&lt;/PRE&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_0-1603131013209.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50806i9547263FD69B5F03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardADeVenezia_0-1603131013209.png" alt="RichardADeVenezia_0-1603131013209.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 18:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/692653#M211035</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-10-19T18:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate limitation of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/700771#M214497</link>
      <description>&lt;P&gt;I actually used this formatting for my data to report he previous 3 months of data.&amp;nbsp; It worked great.&amp;nbsp; Until I tried to report the information for October.&amp;nbsp; And it isn't wrong (at least as far as I know), but it now is out of order.&amp;nbsp; So I have the display of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;August&lt;/P&gt;&lt;P&gt;October&lt;/P&gt;&lt;P&gt;September&lt;/P&gt;&lt;P&gt;YTD&lt;/P&gt;&lt;P&gt;Nothing I do seems to be able to change this order.&amp;nbsp; So frustrating.&amp;nbsp; Any thoughts on how to adjust this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 18:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/700771#M214497</guid>
      <dc:creator>Lost_Gary</dc:creator>
      <dc:date>2020-11-22T18:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate limitation of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/700814#M214518</link>
      <description>&lt;P&gt;The CLASS option / MLF ORDER=DATA PRELOADFMT is used to force a specific ordering of format value when the custom format is built with the NOTSORTED option.&amp;nbsp;&amp;nbsp;However, those mix of options won't work because the formatted value is a map from value &lt;STRONG&gt;range&lt;/STRONG&gt; to another format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
  value mlyear(multilabel notsorted)
    '01jan2000'd-'31dec2005'd = [yymon.]   /* value range to other format */
    low-high = 'All'
  ;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can force a specific order that works with NOTSORTED by enumerating every date in a CNTLIN data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data cntlin;
  retain
    fmtname 'monthsbyday'
    hlo 'MS'  /* options multilabel and notsorted */
  ;
  do start = '01jan2000'd to '31dec2025'd;
    label = put(start,monname.);  /* map date to month name */
    output;
  end;
  do start = '01jan2000'd to '31dec2025'd;
    label = 'YTD ' || put(start,year4.); /* map date to YTD &amp;lt;yyyy&amp;gt; */
    output;
  end;
run;

proc format cntlin=cntlin;
run;&lt;/PRE&gt;
&lt;P&gt;You can use the format for data from a single year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods html file='stocks.html' style=plateau;

proc tabulate data=sashelp.stocks;
title2 'All includes data from years not shown';
var Close;
class date / mlf order=data preloadfmt;
class stock;
table date,stock*close=' '*mean;
format date monthsbyday.;
where year(date) = (2004);
run;

ods html close;&lt;/PRE&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-11-22 204548.png" style="width: 234px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51920i804387539B92DD78/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-11-22 204548.png" alt="Screenshot 2020-11-22 204548.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data being reported spans more than one year you will need an additional class variable YEAR and code&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;table year*date,stock*close=' '*mean;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without the additional year class, the months will aggregate from two years instead of one.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 01:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-limitation-of-output/m-p/700814#M214518</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-11-23T01:51:28Z</dc:date>
    </item>
  </channel>
</rss>

