Hi, please check the code below for creating 4 datasets. also i created a macro for sorting the value in ascending and descending order. %sort is the call. Hope it helps. data above20 below20 above10 below10; input Brand &$10. Year Interbrand_Value :comma. GVKEY Ticker_symbol$; if Interbrand_Value>20 then output above20; if Interbrand_Value<=20 then output below20; if Interbrand_Value>10 then output above10; if Interbrand_Value<=10 then output below10; 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 ; run; %macro sort(dsn=,descending=,var=,out=); %if %lowcase(&descending)=descending %then %do; proc sort data=&dsn out=&out; by &descending &var; run; %end; %else %do; proc sort data=&dsn out=&out; by &var; run; %end; %mend; %sort(dsn=,descending=,var=,out=)
... View more