data table1;
input firm_id year quarter value;
cards;
0001 2000 1 10
0001 2000 3 20
0001 2001 2 45
0001 2001 3 14
0001 2001 4 45
0012 2000 1 34
0012 2000 2 10
0047 2000 1 34
0047 2001 3 34
;
run;
proc sql;
create table want as
select a.*,coalesce(b.value,0) as value
from
(select * from (select distinct firm_id from table1),
(select distinct year from table1),
(select distinct quarter from table1) ) as a
left join table1 as b
on a.firm_id=b.firm_id and a.year=b.year and a.quarter=b.quarter;
quit;
... View more