BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
acordes
Rhodochrosite | Level 12

 Can somebody supply an example for using the 'contribute' option successfully?

 

Shouldn't I get an extra column with the contributing productname?

 

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;
1 ACCEPTED SOLUTION

Accepted Solutions
DerylHollick
SAS Employee

I cannot claim any expertise with this, but I noticed the doc for the doESP= parm says "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."

 

So I think your table just needs to be partitioned prior to the aggregation.  This worked for me:

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;

fetch.JPG

View solution in original post

2 REPLIES 2
DerylHollick
SAS Employee

I cannot claim any expertise with this, but I noticed the doc for the doESP= parm says "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."

 

So I think your table just needs to be partitioned prior to the aggregation.  This worked for me:

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;

fetch.JPG

acordes
Rhodochrosite | Level 12

@DerylHollick brilliant and methodological approach to solve this!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 955 views
  • 1 like
  • 2 in conversation