BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kashili
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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.

PGStats
Opal | Level 21

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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