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;
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;
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;
@DerylHollick brilliant and methodological approach to solve this!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.