Changes

Jump to navigation Jump to search
no edit summary
SELECT 49766
 
===Creating compound variables from variable list and combining them (Jake)===
 
DROP TABLE tobinq;
CREATE TABLE tobinq AS SELECT
conm, gvkey, cusip, datadate, extract(year from datadate) AS year,
LEFT(naics,3) AS naics3, revt,
CASE WHEN (CAST(ceq AS real)) = 0
THEN NULL ELSE (CAST(mkvalt AS real))/(CAST(ceq AS real)) END AS tobinq
FROM compustatpull;
--SELECT 464894
 
DROP TABLE tobinqxcompetition;
CREATE TABLE tobinqxcompetition AS SELECT
conm, gvkey, cusip, datadate, tobinq.year, tobinq.naics3, revt,
LAG(revt) OVER (PARTITION BY gvkey ORDER BY tobinq.year) AS revtlag,
tobinq,
LAG(tobinq) OVER (PARTITION BY gvkey ORDER BY tobinq.year) AS tobinlag,
sumsharesq, countgvkey FROM tobinq
LEFT JOIN competitionfinal ON tobinq.year = competitionfinal.year
AND tobinq.naics3 = competitionfinal.naics3;
--SELECT 464894
 
DROP TABLE CPI;
CREATE TABLE CPI(
year int, avg real, twentytenbase real);
 
\COPY CPI FROM 'CPI Data.txt' WITH DELIMITER AS E'\t' HEADER NULL AS '' CSV;
 
DROP TABLE test;
CREATE TABLE test AS SELECT tobinqxcompetition.*, acq_cusip, pc_cash,
CASE WHEN (Tgt_stockEx = 'NYSE'
OR Tgt_stockEx = 'AMEX'
OR Tgt_stockEx = 'NASDAQ')
THEN 1::int ELSE 0::int END AS Tgt_Public,
date_announced,
date_effective FROM tobinqxcompetition LEFT JOIN sdc ON
LEFT(tobinqxcompetition.cusip, 6) = sdc.acq_cusip AND
EXTRACT
(year from tobinqxcompetition.datadate) = EXTRACT(year from sdc.date_effective);
 
==STATA Work==
668

edits

Navigation menu