Hello,
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,
This isn't an issue with code but an issue with data.
Check your data for those ticker symbols and make sure it's valid.
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.
Thanks
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.
A suggestion to help maintain code and increase program effeciency:
Instead of
data one;
Set x1.portfolio;
run;
data one;
set one;
month = month(date);
year = year(date);
run;
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.
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);
...
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.