Hi PGStats, Could you please advise the program that just removes the following condition? when count(b.rds) >= 3 then mean(b.rds) I would like to have the following result. rds5y 0001 1980 0.05 . 0001 1981 0.02 . 0001 1982 0.03 . 0001 1983 0.04 . 0001 1984 0.04 . 0001 1985 0.05 0.036 0001 1986 0.06 0.036 data have; input gvkey fyear rds; datalines; 0001 1980 0.05 0001 1981 0.02 0001 1982 0.03 0001 1983 0.04 0001 1984 0.04 0001 1985 0.05 0001 1986 0.06 ; proc sql; create table want as select a.gvkey, a.fyear, a.rds, case when count(b.rds) >= 3 then mean(b.rds) else . end as rds5y from have as a left join have as b on a.gvkey=b.gvkey and b.fyear between a.fyear-5 and a.fyear-1 group by a.gvkey, a.fyear, a.rds; select * from want; quit;
... View more