==Cleaning IPO and MA Data==
It is important to follow Ed's direction of cleaning the data using aggregate function before putting the data into excel. This will keep you from a lot of manual checking that is unnecessary. When ready, paste the data you have into an excel file. In that excel file, I made three columns: one to check whether state codes were equivalent, one checking whether the date of first investment was 3 years before the MA or IPO, and one checking whether both of these conditions were satisfied for each company. I did this using simple if statements. This process is manual checking and filtering to see whether matches are correct or not and are thus extremely subjective and tedious. First, I went through and checked the companies that did not have equivalent state codes. If the company was one that I knew or the name was unique to the point that I did not believe the same name would appear in another state, I marked the state codes as equivalent. I did the same for the date of first investment vs MA/IPO date. Then I removed all duplicates that had the marking Warning Multiple Matches, and the data sheets were clean.
==Finding Companies that Underwent IPOs and MAs==
#Load IPOClean and MAClean into the database.
#Perform an INNER JOIN on the two tables in order to find the companies that underwent both MAs and IPOs. Do this by joining on MA.targetnamestd and IPO.issuerstd. Load this table into an excel sheet and manually find which companies you want to keep as MAs and which you want to keep as IPOs. Make sure to keep the portco primary key in this table.
#Load the decided IPO and MA data back into the database, including the primary keys of the portcos.
#Left join the MA table with the IPO table. Select the companies where the IPO table are null as these are the companies that only had MAs. Do the same for MAs. Now you have tables of companies that underwent only MAs and only IPOs.
#Join the companies that underwent IPOs only and the chosen IPOs back to the original key using the primary key of the company which must be in both tables. Repeat this for the MA table.