/* File name: /home/nwu/pledesma/ticker-select.sas               */
/* Used for Feb 18, 2002 introductory workshop to CRSP/Compustat */
/* Written by: P. Ledesma                                        */

filename ticklist 'tickers.txt';

data readlist;
 infile ticklist;
 input smbl $;
 smbl=upcase(smbl);

*proc print data=readlist;

proc sql;
  create table ticksel as select
  namesann.smbl, namesann.coname, namesann.gvkey, namesann.dnum, readlist.*
  from readlist, comp.namesann
  where readlist.smbl = namesann.smbl;
quit;

*proc print data=ticksel;

proc sql;
  create table out.tickselyr as select
  ticksel.*, compann.gvkey, compann.yeara, compann.data6, compann.data36
  from ticksel, comp.compann
  where ticksel.gvkey = compann.gvkey and yeara >= 1996;
quit;

proc print data=out.tickselyr;

endsas;

/* Statements after the ENDSAS statement are ignored by SAS         */
/* Another way of doing the first SQL step with data within program */

data ticksel;
  set comp.namesann;
  where smbl in ("CTAS","PH","CAT","LMT","GWW",
                 "ITT","ADP","FDX","EMR","UNP",
                 "AVY","DHR","PCAR","UTX","ITW",
                 "ETN","FDC","GD","NOC","MMM");
proc print data=ticksel;
  var smbl coname gvkey;