04-23-2017 05:00 PM
I am currently attempting to run regression models on 5 stocks: JPM, PFE, FB, AMZN, and PEP. (2011-2015)
I have combined this data with fama french factors over the past 5 years as well. I have written code to sort the data and run descriptive statistics, however, I am not able to run the regressions because of the error: ERROR: No valid observations are found.
I only see this error at the bottom of my code when I attempt to run two regression models. It staes, for example,
04-23-2017 05:12 PM
I found two issues within the data, but the rest is fine. Is there a way to delete two specific rows of data out of 285? I have everything downloaded from WRDS so I cant necessarily exclude this issue as it will happen every time I try to redownload.
04-23-2017 05:40 PM
Depends on the issue. If you can identify it and flag it with a variable you can add a WHERE clause to the remaining steps or filter it out. Depending on the issue SAS will filter records out, which is why you get a NO RECORDS error because there are no valid records for whatever you're trying to do.
04-24-2017 01:49 PM
A suggestion to help maintain code and increase program effeciency:
month = month(date);
year = year(date);
Do that in one step (and the same for data two).
data one; Set x1.portfolio; month = month(date); year = year(date); run;
You take twice as much computer time with the separate data step to add the two variables. This may not seem like much for a small data set but considering we have users on this forum with datasets with trillions of records the time could be significant.
Also the construct of input and output data set the same are rife with opportunities to cause data problems that are hard to diagnose. And every additional step with the same data set increases the complexity of finding where something went wrong.
04-24-2017 02:06 PM
Most likely the issue is with the regression steps. Perhaps there are not enough valid observations for some TICKER values to SAS to perform a regression.
You could probably output something from PROC MEANS or PROC SQL to test which TICKER values you need to exclude.
proc sql noprint; select quote(trim(ticker)) into :bad_list separated by ' ' from all group by ticker having count(*)=1 ; quit; proc reg data=all; where ticker not in (&bad_list); ...