EASY. data have;
input Brand &$10. Year Interbrand_Value :comma. GVKEY Ticker_symbol$;
cards;
Coca Cola 2001 68,945 003144 KO
Coca Cola 2002 69,637 003144 KO
Coca Cola 2003 70,453 003144 KO
Coca Cola 2004 67,394 003144 KO
Coca Cola 2005 67,525 003144 KO
Coca Cola 2006 67,000 003144 KO
Coca Cola 2007 65,324 003144 KO
Coca Cola 2008 66,667 003144 KO
Coca Cola 2009 68,734 003144 KO
Coca Cola 2010 70,452 003144 KO
Coca Cola 2011 71,861 003144 KO
Coca bbbb 2001 18 003144 Ky
Coca bbbb 2002 20 003144 Ky
Coca bbbb 2003 15 003144 Ky
Coca bbbb 2004 21 003144 Ky
Coca bbbb 2005 16 003144 Ky
Coca bbbb 2006 17 003144 Ky
Coca bbbb 2007 14 003144 Ky
Coca bbbb 2008 20 003144 Ky
Coca bbbb 2009 21 003144 Ky
Coca bbbb 2010 16 003144 Ky
Coca bbbb 2011 18 003144 Ky
;
run;
data p1 p2;
set have(where=(year in (2001 2005 2006)));
if Interbrand_Value gt 20 then output p1;
else if Interbrand_Value lt 10 then output p2;
run;
proc sql;
create table year as select distinct year from have;
create table portfolios1 as
select a.year,Brand ,Interbrand_Value ,GVKEY,Ticker_symbol
from (select year from year where year in (2001 2002 2003 2004)) as a,
(select * from p1 where year=2001)
union all corresponding
select * from p1 where year in (2005 2006)
union all corresponding
select a.year,Brand ,Interbrand_Value ,GVKEY,Ticker_symbol
from (select year from year where year not in (2001 2002 2003 2004 2005 2006)) as a,
(select * from p1 where year=2006);
create table portfolios2 as
select a.year,Brand ,Interbrand_Value ,GVKEY,Ticker_symbol
from (select year from year where year in (2001 2002 2003 2004)) as a,
(select * from p2 where year=2001)
union all corresponding
select * from p2 where year in (2005 2006)
union all corresponding
select a.year,Brand ,Interbrand_Value ,GVKEY,Ticker_symbol
from (select year from year where year not in (2001 2002 2003 2004 2005 2006)) as a,
(select * from p2 where year=2006);
quit;
Ksharp
... View more