// Paul Gronke October 2012 modifications // James Hicks, October 24, 2008 // // Creates daily and cumulative early voting rates for Florida, by party. // Feed it the processed file from create-fl08. */ // NOTE: must have 'dups' installed -- ssc inst dups */ // Original files acccessed at this URL: // https://countyballotreports.elections.myflorida.com/AbsenteeEarlyVotingReports // // Files downloaded using Site Sucker // First, create a list of the files in the 'data/2012' directory // and then we will use this list as input into our insheet // command // set more off local dirname "/Users/paulgronke/Downloads/florida/countyballotreports.elections.myflorida.com/AbsenteeEarlyVotingReports/ViewReport/2012/" ! ls `dirname'*.txt > filelist.txt // Creates a text file of file names // // Open the list of files, and process the first line // in order to create a "master" file for appending // capture file close myfile // This is needed in case we are running // the program a second time after it has // crashed. It closes the file in case // Stata thinks it is still open file open myfile using "filelist.txt", read // Read the text file file read myfile line // Read the first line (filename) insheet using "`line'", clear // Input the file save fl12.dta, replace // Save the "masterfile" drop _all // Drop the first line that // is still in memory /* now repeat the process until the end of the file listing */ file read myfile line while r(eof)==0 { // Continue to read (line 2 onward) // Read file r(eof)==0 means NOT end of file insheet using "`line'" // Now read files 2-67 capture drop absprecinct // Variable byte in some files capture drop precinct // and here as well append using fl12.dta // Append the new file onto the end of main file save fl12.dta, replace // And save the result drop _all // Drop the last line in memory file read myfile line // ... and continue to next line (file) } /* drop all once more, since Stata currently has the last line in memory */ drop _all /* re-open the now complete master dataset */ use fl12 /* check for duplicate observations, and drop them */ rename fvrsvoteridnumber voter_id dups voter_id, drop key(voter_id) // May need to download "dups" program /* Convert the date string into a true date variable */ gen date = date(dateofearlyvote, "MDY") format date %d sort date /* save! ready for analysis */ save fl12, replace