Hello all, I have the code below that needs to be applied in all stocks of the data. So, if i have 800 stocks, I should run the code 800 times, each time changing the stock name (red highlighted). How can I make SAS automatically run the code for each stock and then save it as a file with the name of each stock? Many thanks in advance proc sql; create table C as select* from work.data where stock = "ACERALIA"; quit; proc sql; create table b as select date,code,value from c; quit; proc sql; create table f as select a.*,b.* from work.Date as a left join work.b as b on a.date=b.date; quit; proc sort data=work.f nodupkey;by code date;run; data a; set f; format date monyy7.; run; proc sql; create table a_ as select distinct date,0.1 as code from a; quit; data a2; set a a_;run; proc sort data= a2; by code date;run; proc transpose data=a2 out=a3(where=(code^=0.1)); by code; id date; var value; run; data work.a4; set work.a3; drop _NAME_; run; Data old; Code=0 Mar1995=1 jun1995=2 sep1995=3 dec1995=4 mar1996=5 jun1996=6 sep1996=7 dec1996=8 mar1997=9 jun1997=10 sep1997=11 dec1997=12 mar1998=13 jun1998=14 sep1998=15 dec1998=16 mar1999=17 jun1999=18 sep1999=19 dec1999=20 mar2000=21 jun2000=22 sep2000=23 dec2000=24 mar2001=25 jun2001=26 sep2001=27 dec2001=28 mar2002=29 jun2002=30 sep2002=31 dec2002=32 mar2003=33 jun2003=34 sep2003=35 dec2003=36 mar2004=37 jun2004=38 sep2004=39 dec2004=40 mar2005=41 jun2005=42 sep2005=43 dec2005=44 mar2006=45 jun2006=46 sep2006=47 dec2006=48 mar2007=49 jun2007=50 sep2007=51 dec2007=52 mar2008=53 jun2008=54 sep2008=55 dec2008=56 mar2009=57 jun2009=58 sep2009=59 dec2009=60 mar2010=61 jun2010=62 sep2010=63 64;run; Data new; retain code Mar1995 jun1995 sep1995 dec1995 mar1996 jun1996 sep1996 dec1996 mar1997 jun1997 sep1997 dec1997 mar1998 jun1998 sep1998 dec1998 mar1999 jun1999 sep1999 dec1999 mar2000 jun2000 sep2000 dec2000 mar2001 jun2001 sep2001 dec2001 mar2002 jun2002 sep2002 dec2002 mar2003 jun2003 sep2003 dec2003 mar2004 jun2004 sep2004 dec2004 mar2005 jun2005 sep2005 dec2005 mar2006 jun2006 sep2006 dec2006 mar2007 jun2007 sep2007 dec2007 mar2008 jun2008 sep2008 dec2008 mar2009 jun2009 sep2009 dec2009 mar2010 jun2010 sep2010;set a4;run; proc sql; create table a5 as select a.*,b.* from work.funds as a left join work.a4 as b on a.code=b.code; quit; data asigns; set WORK.a5; array vol(63) mar1995 --sep2010; array si (62) $ si1-si62; do i= 2 to 63; if vol(i) > vol(i-1) then si(i-1)='+'; else if vol(i) < vol(i-1) then si(i-1)='-'; else si(i-1)='&'; end; RUN;
... View more