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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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