You may want something like this:
/* Create the month variable into a string YYYY/MM */
data analysts0;
set <your data>;
format month $7.;
month=cats(year(date),'/',put(month(date),z2.));
run;
/* Sort so you can do the by processing required for counting */
proc sort data=analyst0 out=analyst1;
/* You need to include the date in the sort so the most recent is last */
by ticker month date;
run;
/* Count */
data count;
retain n_fem n_male 0;
set analyst1;
by ticker month;
if first.ticker of first.month then do;
n_fem=0;
n_male=0;
end;
else do;
if gender=1 then n_fem+1;
else if gender=0 then n_male+1;
else put 'Huh?';
end;
/* this outputs only the values you need.*/
if last.ticker or last.month then output;
run;
This should give you the general idea - I don't have access to SAS right now so I can't check the code. See the documentation for retain and by processing in the data step for more details.
Ville Koskinen
2010-04-06 07:14:33