Date: Wed, 16 Dec 2009 13:18:42 -0600
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Loop within a Proc Mixed or Proc Autoreg statement
In-Reply-To: <e3868ee4-8eb5-4a1a-949a-978bc0d1c783@f6g2000vbp.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Here is example of TRANSPOSE and BY group processing. Including
creating a sample data set.
data have;
array ptf[25];
do id = 1 to 10;
y = rannor(12345);
do _n_ = 1 to dim(ptf);
ptf[_n_] = rannor(0);
end;
output;
end;
run;
proc transpose out=tall;
by id y;
var ptf:;
run;
data tall;
set tall;
attrib ptf length=8 label='Portfolio';
ptf = input(substr(_name_,4),f8.);
run;
proc sort data=tall;
by ptf;
run;
proc mixed data=tall;
by ptf;
model y = col1 / s;
repeated / subject=intercept type=ar(1);
run;
On 12/16/09, SAS Newbie <hegkim@gmail.com> wrote:
> Hello,
>
> I have a spreadsheet of time series data. I have the returns of 25
> different indices. And I want to do a AR 1 model of the market returns
> (var y) against each of the 25 portfolios. I am using a Proc Mixed or
> Proc Autoreg function. Instead of manually copying and pasting 25 Proc
> Mixed commands, is there any way I can write a loop within the Proc
> Mixed function or write a macro to call it within the Proc Mixed so
> that I can do a univariate AR1 regression against each of the
> portfolios?
> "ptf1" is the first portfolio's variable name. The next 24 portfolios
> are all in adjacent columns and are"ptf2, ptf3, .. ptf 25".
>
> This is my code:
> proc mixed data=returns1;
> model y = ptf1 / s; repeated / subject=intercept type=ar(1); run;
>
> Thanks!
>
|