06-30-2014 08:44 AM
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!
06-30-2014 09:15 AM
proc sort data=have (keep=director year) out=inter nodupkey;
by director year;
data want (keep=director);
if first.director then control = ' '; * six blanks;
substr(control,year-&start,1) = 'X';
if last.director and control = 'XXXXXX' then output;
Set macro variable start to a suitable start year.
07-01-2014 05:09 AM
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!
07-01-2014 05:20 AM
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:
into :MYLIST separated by '","'
from (select distinct DIRECTORID,
count(YEAR) as CNT
where CNT = 6;
This list could then be used to filter tha dataset,
where directorid in ("&MYLIST.");
07-01-2014 06:53 AM
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.