<?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: cas action aggregate, contribute variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/861379#M340259</link>
    <description>&lt;P&gt;I cannot claim any expertise with this, but I noticed the doc for the doESP= parm says "&lt;SPAN&gt;when set to True, the action can take advantage of partitioning and ordering on the input table. You must specify the groupBy parameter for the input table. The ID variable must be specified as the last groupBy parameter and in the orderBy parameter."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So I think your table just needs to be partitioned prior to the aggregation.&amp;nbsp; This worked for me:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.PRICEDATA;
set SASHELP.PRICEDATA;
run;

proc cas;
table.partition / casout={caslib="CASUSER",name="PRICEDATA", replace=true},
  table={name="PRICEDATA",caslib="casuser", 
  groupby={{name="regionname"}}
  orderby={{name="date"}}
  };
run;

aggregation.aggregate / 
  table={name="PRICEDATA",caslib="casuser",
  where="1=1", 
  groupby={ {name="regionname"}, {name="date" , format="yyq6."}}
          }
  varspecs={
            {subset="sum", name="sale", columnnames="sum_sale"}
            }
  casout={name="nodup2", caslib='casuser', replace=TRUE} 
  savegroupbyraw=TRUE, savegroupbyformat=false, raw=TRUE,
  windowInt="quarter",
  contribute="productname",
  keepRecord=TRUE,
  doESP=TRUE,
  interval="quarter",
  jumpingWindow=false,
  id="date" ;

table.fetch / table={name="nodup2", caslib="casuser"};
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fetch.JPG" style="width: 927px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80930i27C2A31DEB4E49EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="fetch.JPG" alt="fetch.JPG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2023 14:03:27 GMT</pubDate>
    <dc:creator>DerylHollick</dc:creator>
    <dc:date>2023-02-28T14:03:27Z</dc:date>
    <item>
      <title>cas action aggregate, contribute variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/860504#M339933</link>
      <description>&lt;P&gt;&amp;nbsp;Can somebody supply an example for using the 'contribute' option successfully?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Shouldn't I get an extra column with the contributing productname?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.PRICEDATA;
set SASHELP.PRICEDATA;
run;

proc cas;
aggregation.aggregate / 
  table={name="PRICEDATA",caslib="casuser", 
  where="1=1", 
  groupby={ {name="regionname"}, {name="date" , format="yyq6."}}
          }
  varspecs={
            {subset="sum", name="sale", columnnames="sum_sale"}
            }
  casout={name="nodup2", caslib='akaike', replace=true} 
  savegroupbyraw=true, savegroupbyformat=false, raw=true,
  windowInt="quarter"
  contribute="productname"
  keepRecord=false
  doESP=true
  interval="quarter"
  jumpingWindow=false
  id="date" ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/860504#M339933</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-02-23T17:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: cas action aggregate, contribute variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/861379#M340259</link>
      <description>&lt;P&gt;I cannot claim any expertise with this, but I noticed the doc for the doESP= parm says "&lt;SPAN&gt;when set to True, the action can take advantage of partitioning and ordering on the input table. You must specify the groupBy parameter for the input table. The ID variable must be specified as the last groupBy parameter and in the orderBy parameter."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So I think your table just needs to be partitioned prior to the aggregation.&amp;nbsp; This worked for me:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.PRICEDATA;
set SASHELP.PRICEDATA;
run;

proc cas;
table.partition / casout={caslib="CASUSER",name="PRICEDATA", replace=true},
  table={name="PRICEDATA",caslib="casuser", 
  groupby={{name="regionname"}}
  orderby={{name="date"}}
  };
run;

aggregation.aggregate / 
  table={name="PRICEDATA",caslib="casuser",
  where="1=1", 
  groupby={ {name="regionname"}, {name="date" , format="yyq6."}}
          }
  varspecs={
            {subset="sum", name="sale", columnnames="sum_sale"}
            }
  casout={name="nodup2", caslib='casuser', replace=TRUE} 
  savegroupbyraw=TRUE, savegroupbyformat=false, raw=TRUE,
  windowInt="quarter",
  contribute="productname",
  keepRecord=TRUE,
  doESP=TRUE,
  interval="quarter",
  jumpingWindow=false,
  id="date" ;

table.fetch / table={name="nodup2", caslib="casuser"};
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fetch.JPG" style="width: 927px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80930i27C2A31DEB4E49EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="fetch.JPG" alt="fetch.JPG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 14:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/861379#M340259</guid>
      <dc:creator>DerylHollick</dc:creator>
      <dc:date>2023-02-28T14:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: cas action aggregate, contribute variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/861401#M340269</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3174"&gt;@DerylHollick&lt;/a&gt;&amp;nbsp;brilliant and &lt;SPAN&gt;methodological approach to solve this!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 14:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cas-action-aggregate-contribute-variable/m-p/861401#M340269</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-02-28T14:39:36Z</dc:date>
    </item>
  </channel>
</rss>

