data test;
input stkcd year variable;
cards;
1 1999 1
1 2004 2
1 2007 2
1 2009 6
1 2011 1
2 2003 1
2 2007 2
2 2011 3
3 2003 1
4 2002 2
4 2003 1
4 2004 1
4 2005 1
4 2007 3
4 2008 1
4 2009 1
4 2010 1
4 2011 1
4 2012 9
4 2013 1
4 2014 5
5 2014 1
;
data allyear;
do year=1999 to 2015;
output;
end;
run;
proc sql;
create table wanted as
select a.stkcd, a.year, variable
from
(select * from
(select distinct stkcd from test), (select distinct year from allyear)) a
left join test b
on a.stkcd=b.stkcd and a.year=b.year;
quit;