BookmarkSubscribeRSS Feed
wegweiax
Calcite | Level 5

So I am having a problem creating a table in SAS using SQL. I have two files, one that contains files on a firm (which i need information on the Gender of the CEO, which is one of the columns) and a financial ratio which is on the other file (MRET3). The data is on different firms data for 5 consecutive years, this is what i need to do:

I need to average the ROE by firm over those 5 years and then only include companies that have a female CEO.

This is how far I got and I cannot seem to get it to work:

Proc SQL;

Create Table Q11 as

Select Alex.MRET3

Create Table Q11a

Select AVG(MRET3) From Q11 By Alex.year where Jim.gender='FEMA';

Proc Print data=Q11a;

Run;

So as you can see, I am trying to grab MRET from file Alex and create a new table and average them by year but only where the ceo is female.

Please help, I would really appreciate it.  If there is anything confusing let me know and I will explain. Thanks

2 REPLIES 2
LinusH
Tourmaline | Level 20

The first create table statement seems obsolete.

By should by Group By, and you probably want to have year in your select, otherwise your result will be hard to interpret.

Data never sleeps
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Something like (and this is guessing without example data):

proc sql;

     create table WANT as

     select     CEO.CEO,

                    CEO.GENDER,

                    MRET.AVG_MRET3

     from        (select distinct CEO,GENDER from CEO where GENDER="Female") CEO

     left join     (select distinct

                                  CEO,

                                  AVG(MRET3) as AVG_MRET3

                       from    MRET3

                       group by CEO,

                                       YEAR) MRET

     on            CEO.CEO=MRET.CEO;

quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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