BookmarkSubscribeRSS Feed
jbanghoj
Calcite | Level 5

I have a problem in SAS which is the following:

For several firms I have several people (directors) for 6 different years.

I wish to pick one person from each firm, who has all six years of observations and perform a regression analysis on these people.

So I need help to get one person from each firm with all sex years of observation.

I have a firmID, DirectorID and a Year variable (from 2002-2004 and from 2006-2008)

I you need more detail on the problem please let me know!

Thanks!

4 REPLIES 4
Kurt_Bremser
Super User

proc sort data=have (keep=director year) out=inter nodupkey;

by director year;

run;

data want (keep=director);

set inter;

by director;

retain control;

if first.director then control = '      '; * six blanks;

substr(control,year-&start,1) = 'X';

if last.director and control = 'XXXXXX' then output;

run;

Set macro variable start to a suitable start year.

jbanghoj
Calcite | Level 5

Thanks alot for the reply.

I do not see how this will help me pick one director from each firm as firmID is deleted from the sample.

How do I set the macro variable start to a suitable start year?

I have observations from the years 2002-2004 and 2006-2008 - 6 years in total.

Thank you once again!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Can I suggest you post some test data and required output.  Its quite difficult to guess the circumstances.  At a guess you could get those directors with six years by:

proc sql;

     select     DIRECTORID

     into         :MYLIST separated by '","'

     from        (select     distinct DIRECTORID,

                                    count(YEAR) as CNT

                     from         HAVE)

     where     CNT = 6;

quit;

This list could then be used to filter tha dataset,

data want;

     set have;

     where directorid in ("&MYLIST.");

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1398 views
  • 0 likes
  • 3 in conversation