Hello,

I am attempting to run the same code over two different subfolders. My thinking was that I would set the working directory, then set a global macro for a subdirectory, then a local macro for each folder over which I needed to loop the same code. Here is what I have:

Code:
clear 

global root = "/Users/gsaldutte/Downloads/opm-federal-employment-data/opm-federal-employment-data/data/"

cd "$root"

global dataDir1="../1973-09-to-2014-06"
global dataDir2="../2014-09-to-2016-09"
global dataDir3="../2016-12-to-2017-03"

local subfolders `""$dataDir1/dod/dynamic" "$dataDir1/non-dod/dynamic""'

foreach f of local subfolders{

forval year = 1982/2013{

    foreach mth in DEC JUN MAR SEP {

        infix float psuedo_id 1-9 str employee_name 10-32 str agency 33-36 ///
        str accession_indicator 37-38 float effective_date 39-46 str age ///
        47-52 str pay_plan 53-54 str grade 55-56 str los_level ///
        57-62 str duty_station 63-71 str occupation 72-75 str occ_cat 76 ///
        str adj_basic_pay 77-82 str type_appointment 83-84 str work_sched 85 ///
        using "`f'/`mth'`year'.DOD.FO05M4.TXT", clear
         
        gen date2=date(string(effective_date,"%8.0f"),"YMD")
        format date2 %td
        
        replace effective_date = date2
        
        drop date2
        
        save "Stata/`mth'`year'.DOD.FO05M4.dta", replace
        }
    }
}
Stata returns the error file ../1973-09-to-2014-06/dod/dynamic/DEC1982.DOD.FO05M4.TXT not found. To me this suggests that the problem are the two periods preceding years in the dataDir globals, but I have had success using this format before.

Thanks.