Programming the statistical procedures from SAS

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

Reply
New Contributor
Posts: 2

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

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!

Super User
Posts: 7,093

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

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 2

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

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!

Super User
Super User
Posts: 7,565

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

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;

Super User
Posts: 7,093

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

Then you basically have to include the firmID in the by statements, extend the control string and compare for the right pattern(s) at the end.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 4 replies
  • 229 views
  • 0 likes
  • 3 in conversation