sas proc iml regression

bran

New Member
Hi
I ma having some real trouble with proc iml. I need to create a new marketing mix model andprovide some regression analysis.

I can solve the equations for each month (sas code below), but i really need the results as a regression.

basic equation id
- - --- --- -- -
|x | |a1 b1 c1 d1 e1 | | f |
|y | = |a2 b2 c2 d2 e2 | | g |
|z | |a3 b3 c3 d3 e3 | | h |
- - --- --- | i |
| j |

I can solve this as an equation, but the figures change by month. So I would like to generate a regression formula for x, y and z

- - -- ---
|x |= |a1f + b1g + c1h + d1i + e1j + intercept |
|y |= |a2f + b2g + c2h + d2i + e2j + intercept |
|z |= |a3f + b3g + c3h + d3i + e3j + intercept |

so far my iml code is looking quite poor ( printed below). Am I approaching this from the wrong direction? Currently all I need to calculate will be the parameter estimates.
If you need sample of data or any further details please ask.

Thanks
Alun

%macro matrix(var1);

proc iml;
* Read data into IML ;
use work.sales;
read all var {sales} into a where (dat="&var1");
use work.cost;
read all var {cost} into da where (dat="&var1");
d = da`; *transform the data;
di = ((d*da)**-1)*d;
print a;
print d;
print da;
print di;
res=a* di;
sales={direct, direct, direct,direct, direct, direct,direct, direct, direct,
indirect, indirect, indirect,indirect, indirect, indirect,indirect, indirect, indirect,
agg, agg, agg,agg, agg, agg,agg, agg, agg};
date = {&var1, &var1, &var1,&var1, &var1, &var1,&var1, &var1, &var1,
&var1, &var1, &var1,&var1, &var1, &var1,&var1, &var1, &var1,
&var1, &var1, &var1,&var1, &var1, &var1,&var1, &var1, &var1};
print res [rowname=sales];;

create work.&var1 var {date sales res da} ; /****** this and next line ***/
append ; /** LETS UYOU STORE THE RESULT INTO A FILE CALLED WORK.RES **/

quit;

%mend;

%matrix(JAN06);
%matrix(FEB06);
%matrix(MAR06);
%matrix(APR06);
%matrix(MAY06);
%matrix(JUN06);
%matrix(JUL06);
%matrix(AUG06);
%matrix(SEP06);
%matrix(OCT06);
%matrix(NOV06);
%matrix(DEC06);
%matrix(JAN07);
%matrix(FEB07);
%matrix(MAR07);
%matrix(APR07);
%matrix(MAY07);
%matrix(JUN07);
%matrix(JUL07);
%matrix(AUG07);
%matrix(SEP07);
%matrix(OCT07);
%matrix(NOV07);
%matrix(DEC07);
%matrix(JAN08);
%matrix(FEB08);
%matrix(MAR08);
%matrix(APR08);
%matrix(MAY08);

data work.all;
set work.JAN06 work.FEB06 work.MAR06 work.APR06 work.MAY06
work.JUN06 work.JUL06 work.AUG06 work.SEP06 work.OCT06
work.NOV06 work.DEC06 work.JAN07 work.FEB07 work.MAR07
work.APR07 work.MAY07 work.JUN07 work.JUL07 work.AUG07
work.SEP07 work.OCT07 work.NOV07 work.DEC07 work.JAN08
work.FEB08 work.MAR08 work.APR08 work.MAY08;
run;