I am trying to use -zipuse- to use and append a number of files that are inside some zip folders contained in a specific directory. Each zip folder contains one .dta file and the name of the .dta files that are inside the zip folders are a random list of digits and characters (e.g. aa48229snfjka.dta). Before giving further details, I'd like to specify that I am using Stata 13 on Windows 10, and that both Stata and the operating system are up to date.
The code I have been trying to use is the following:
Code:
local sourcedir "C:/DocumentiRV/ERIM/research/writing/ownership characteristics and tax inversions/2020/data/shareholder information"
local fls : dir "`sourcedir'" files "*people.zip", respectcase
local flsC : dir "`sourcedir'" files "*companies.zip", respectcase
tempfile people companies
save `people', emptyok
save `companies', emptyok
    foreach f of local fls {
            zipuse "`sourcedir'/`f'", clear
            append `people'
            save `people', replace        
    }
    foreach fC of local flsC {
            zipuse "`sourcedir'/`fC'", clear
            drop annualreportdate rowtype
            duplicates drop
            append `companies'
            save `companies', replace        
    }
merge m:1 directorid using `people', nogen
zipsave "`sourcedir'/BoardEx All"Code:
----------------------------------------------------------------------- end zipuse._ok2use ---
  - tempfile tmpdat
  - if "`dtafile'" == "" {
  = if "" == "" {
  - shell unzip -p "`zipfile'" > `tmpdat'
  = shell unzip -p "C:/DocumentiRV/ERIM/research/writing/ownership characteristics and tax inversi
> ons/2020/data/shareholder information/BoardEx Europe people.zip" > C:\Users\RICCAR~1\AppData\Loc
> al\Temp\ST_02000003.tmp
  - }
  - else {
    shell unzip -p "`zipfile'" "`dtafile'" > `tmpdat'
    }
  - use `initlist' `usind' `tmpdat', clear `options'
  = use   C:\Users\RICCAR~1\AppData\Local\Temp\ST_02000003.tmp, clear 
file C:\Users\RICCAR~1\AppData\Local\Temp\ST_02000003.tmp not Stata format
    if "`dtafile'" == "" {
    global S_FN = "`zipfile'"
    }
    else {
    global S_FN = "`dtafile'"
    }
    }
  --------------------------------------------------------------------------------- end zipuse ---Code:
shell which zip
I hope someone can offer advice or a workaround to avoid using zipuse altogether.
0 Response to -zipuse- unable to recognize .dta files inside zip folders
Post a Comment