Hello,

I previously posted code in a thread, and with the help of a couple Statalist users came up with:

Code:
cd "/Users/gsaldutte/Downloads/opm-federal-employment-data/opm-federal-employment-data/data/"

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 "`f'/Stata/`mth'`year'.DOD.FO05M4.dta", replace
        }
    }
}
Unfortunately, I neglected that, while the files in the dod folder do end with "FO05M4," they end with "FO05M3" in the non-dod folder. Would it be possible to set up a loop so that the code would call FO05M4 files while in the dod folder, and FO05M3 files while the non-dod folder?

Thank you.