/* 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 $;

*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;

*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;

proc print data=out.tickselyr;


/* 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",
proc print data=ticksel;
  var smbl coname gvkey;