Try this approach : /* create random test data for 5 stocks with missing values */ data test(drop=s); array stock{5}; format date date9.; do date = '01JAN2010'd to '31DEC2011'd; if weekday(date) in (2,3,4,5,6) then do; do s = 1 to dim(stock); stock{s} = ifn(rand('UNIFORM') < 0.9, 100 + 10*rand('NORMAL'), .); end; output; end; end; run; /* List the stock variable names */ %let stocks=stock1-stock5; proc transpose data=test out=temp0; by date; var &stocks.; run; proc sql; create table temp1 as select intnx("WEEK", date, 0) as week format=date9., _name_, mean(COL1) as meanStock from temp0 group by calculated week, _name_ having count(COL1) >= 4; drop table temp0; quit; proc transpose data=temp1 out=want(drop=_name_); by week; id _name_; var meanStock; run; PG
... View more