Date: Wed, 16 Jan 2008 23:14:29 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: SAS rolling regression
On Wed, 16 Jan 2008 20:57:55 -0600, data _null_, <datanull@GMAIL.COM> wrote:
>Yes, I see the vague reference to ID and WEEK-ID. You are correct as
>usual. You will have to show me how to do the self-join.
Maybe
create view rolling10 as
select rolls.companyID
, rolls.weekID as rollid
, windows.weekID
, windows.y
from weeks as rolls join weeks as windows
on rolls.companyID = windows.companyID
where rollid LE windows.weekID LE rollid + 9
group by rolls.companyID, rollid
having count(*) = 10
order by rolls.companyID, rollid, weekID
;
Then the BY statement for PROC REG is
by companyID rollid;
>
>On Jan 16, 2008 7:01 PM, Howard Schreier <hs AT dc-sug DOT org>
><nospam@howles.com> wrote:
>>
>> On Wed, 16 Jan 2008 18:24:18 -0600, data _null_, <datanull@GMAIL.COM> wrote:
>>
>> >This may be close to what you want.
>> >
>> >proc plan seed=2021472219;
>> > factors
>> > weekID = 105 ordered
>> > y = 1 of 50 random / noprint;
>> > output out=work.weeks;
>> > run;
>> >data work.rolling10;
>> > set work.weeks(rename=(weekID=rollID));
>> > if _n_+9 lt nobs then do point = _n_ to _n_+9;
>> > set work.weeks point=point nobs=nobs;
>> > output;
>> > end;
>> > run;
>> >proc reg noprint outest=est;
>> > by rollid;
>> > model y = weekID;
>> > run;
>> >proc print;
>> > run;
>> >
>> >On Jan 16, 2008 5:23 PM, Dave Smith <daveyboysmith_123@yahoo.com> wrote:
>> >> hello people
>> >>
>> >> I am a newbie to SAS .. I tried searching the SAS archives but
couldnot find
>> >> what I am looking for,
>> >>
>> >> I need to run rolling regression in SAS, I have the following data
>> >>
>> >> id week-id price(response) x1 x2
>> >>
>> >> I need to run regression by id. week-id is an indicator of week number
from
>> >> 1 to 105 ,i need to run rolling regression using 10 week periods. This
means
>> >> for id 1 I run regression for week_id 1 to 10 regression and then
regression
>> >> on observation 2 to 11 etc. and then I do the same for id 2 etc
>> >>
>> >> I read on SAS listserv that using macro is not good as the calculations
>> >> become too many,
>> >>
>> >> Thank you for any help
>> >>
>> >> Dave Smith
>> >>
>>
>> I think the input is more like
>>
>> proc plan seed=2021472219;
>> factors
>> companyID = 3 ordered
>> weekID = 105 ordered
>> y = 1 of 50 random / noprint;
>> output out=work.weeks;
>> run;
>>
>> So using the NOBS= result as a cutoff won't quite do it. I would probably
>> use a self-join in PROC SQL to generate the expanded data set or view.
>>
|