Changes

Jump to navigation Jump to search
==Importing the CRSP data into the `winner' database (Amir) ==
Two important files:
Project --> Winner's Curse --> Data --> SQL --> CRSP_NOTES
Project --> Winner's Curse --> Data --> SQL --> CRSP_CODES
Data file is located in: E:\McNair\Projects\Winner's Curse\Data\CRSP-Oct10-c30cc89e52b70545-1.txt
Entered the following command in the terminal to read the header:
head -1 CRSP-oct10.txt
List of variables in the CRSP-oct10.txt
The We have unexpected data file, crsp-oct10.txt, has a header types in the first linefew columns. I couldn't find an argument for copy from function to account for this. So, IWe'll just delete the first line from the file and try again to copy the start by copying data into the crsp table.   tail -n +2 CRSP-oct10.txt > CRSP-oct10NH.stdout I renamed the output to CRSP-NH, NH for no header. Let's take a look if the header is actually removed.   head -2 CRSP-NH.txt  output: 10000 1986/01/06 7952 68391610 -0.000138 0.001926 10000 1986/01/07 3 3990 68391610 OMFGA OPTIMUM MANUFACTURING INC Q 7952 68391610 -2.56250 1000 C 3680 0.013809 0.011061 Now, let's copy the data from CRSP-NH.txt into the CRSP table.   \COPY crsp FROM '/bulk/WinnersCurse/CRSP-NH.txt'; --ERROR: invalid input syntax named CRSPtmp with varchar type for integer: "" --CONTEXT: COPY crsp, line 1, column excode: "" To avoid problems such most of the one above, I'll just copy all the variables as varcharfields.  
CREATE TABLE CRSPtmp (
trade varchar(10),
EQRET varchar(10),
VRET varchar(10) );
\COPY CRSPtmp FROM '/bulk/WinnersCurse/CRSP-NH.txt'; --COPY 64614281
SELECT * FROM CRSPtmp limit 10;

Navigation menu