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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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