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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 976 views
  • 1 like
  • 2 in conversation