DATA Step, Macro, Functions and more

proc reg issue

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

proc reg issue

I have timeseries of 10 different stocks for 25 days. I first normalize ther price of each stock for every day. Then I have to run regression of every stock with 9 other stocks for every day separately and report out SSE in ascending order(so I will have 9*10*SSE).

*this works correctly;

proc standard data=r.mktdata MEAN=0 STD=1 out=r.norm_mktdata;

      by symbol date;

   var zprice;

   

   run;

*following is where the problem is;

proc reg data=r.norm_mktdata ;

   by symbol date;

   zprice=zprice;

   run;

However I get following error "ERROR 180-322: Statement is not valid or it is used out of proper order." I believe I am getting this error because dependent and indepdent variables are same in proc reg. How to 1)fix this error and 2)generate SSE in ascending order

Thank you


Accepted Solutions
Solution
‎03-14-2013 07:53 PM
Super User
Posts: 17,819

Re: proc reg issue

Your missing a model statement and having the same dependent and independent variable wouldn't result in anything.

I think you'll need to reformat your data so that you have two different variables. If you're doing things over time you may want to refer to the time series procedures.

View solution in original post


All Replies
Solution
‎03-14-2013 07:53 PM
Super User
Posts: 17,819

Re: proc reg issue

Your missing a model statement and having the same dependent and independent variable wouldn't result in anything.

I think you'll need to reformat your data so that you have two different variables. If you're doing things over time you may want to refer to the time series procedures.

Respected Advisor
Posts: 4,646

Re: proc reg issue

Following 's comments, and assuming there is a time variable in r.norm_mktData, you would need something like (untested) :

/* Reshape the data into a WIDE format */

proc sort data=r.norm_mktdata out=mktdataSort; by date time symbol; run;

proc transpose data=mktdataSort out=mktDataTable prefix=s_;
by date time;
var zprice;
id symbol;
run;

/* Create copies of the data where each symbol becomes the dependent

     variable and is removed from the regressors */

data mktDataAll;
length depName $32;
set mktDataTable;
array s{*} s_:;
do _n_ = 1 to dim(s);
     depName = vname(s{_n_});
     depValue = s{_n_};
     call missing(s{_n_});
     output;
     s{_n_} = depValue;
     end;
run;

/* Run all regressions, collect the results in dataset mktDataSSE */

proc sort data=mktDataAll; by date depName time; run;

proc reg data=mktDataAll SSE outest=mktDataSSE noprint;
by date depName;
model depValue = s_:;
run;

The SSEs should be in dataset mktDataSSE.

PG

PG
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 181 views
  • 3 likes
  • 3 in conversation