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

I have a large dataset in excel to sort for firms stock data. On one sheet I have returns, sheet 2 has market cap, sheet 3 has dividend yield. Because not all companies pay dividends, I need to delete firms that are not included on the dividend yield sheet. Is there a procedure I can run in sas that will only count firm data that is included in all dataset sheets?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your code doesn't match mine. I have select * which means select everything and you have select name, which selects only the name variable. Please post your code and results as texts, trying to read code off images is not fun.

 


@starkey09 wrote:

Thanks. That works to filter the names. However, the data that is attributed to each of those firm names is missing. The result gave me just a list of the names on the data set. I have attached a photo- perhaps I made an error?DIV.PNGTRNZX.PNGFiltered.PNG


 

View solution in original post

4 REPLIES 4
Reeza
Super User

You can filter your data relatively easy via PROC SQL.

It would be as a simple as

Proc sql;
Create table filtered as
Select * from returns
Where firm in (select distinct firm from dividend);
Quit.

You would have to replace the table and variable names as appropriate.


@starkey09 wrote:

I have a large dataset in excel to sort for firms stock data. On one sheet I have returns, sheet 2 has market cap, sheet 3 has dividend yield. Because not all companies pay dividends, I need to delete firms that are not included on the dividend yield sheet. Is there a procedure I can run in sas that will only count firm data that is included in all dataset sheets?


 

starkey09
Calcite | Level 5

Thanks. That works to filter the names. However, the data that is attributed to each of those firm names is missing. The result gave me just a list of the names on the data set. I have attached a photo- perhaps I made an error?DIV.PNGTRNZX.PNGFiltered.PNG

Reeza
Super User

Your code doesn't match mine. I have select * which means select everything and you have select name, which selects only the name variable. Please post your code and results as texts, trying to read code off images is not fun.

 


@starkey09 wrote:

Thanks. That works to filter the names. However, the data that is attributed to each of those firm names is missing. The result gave me just a list of the names on the data set. I have attached a photo- perhaps I made an error?DIV.PNGTRNZX.PNGFiltered.PNG


 

starkey09
Calcite | Level 5

Thank you very much. That has worked perfectly.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1129 views
  • 1 like
  • 2 in conversation