Hello. These are the local macros I need for my do-file to work:
The last 3 locals refer to filenames that are stored at different places of my working directory. Now have a look at this code:
For some reason, when the loop is running for the last elements of my three locals (INDIVIDU, MENAGE, TRANSMISSION), it seems like the code creates empty local. This is the result of the commands I highlighted :
In the 2010 folder, the correct file is menage.dta and transmission.dta. Yet I don't know why the code is creating a blank void local macro for what is supposed to be MENAGE.dta and TRANSMISSION.dta since the files do not exist. Normally the code should be at the "continue" part. In the last two remaining lines, INDIVIDU.dta is the correct file yet it created a blank local for a non-existent file called individu.dta. So I'm thinking there's definitely a case-sensitivity issue in my code but I don't know where. Can someone help me? Thanks!
When I remove the respectcase option the code runs smoothly, but I don't want to do this because there might be Mac users among my working team.
Code:
* II. Other macros definition **# If interested in less waves - EDIT HERE local wave 1986 1992 1998 2004 2010 2014 2018 **# If interested in less tables - EDIT HERE local tables indiv hh transm // Individual-related table names local indiv actfin86 act921 individu INDIVIDU // Household-related table names local hh actfin86 act921 menage MENAGE // Transmission-related table names local transm actfin86 act922 transfer transm transmission TRANSMISSION
Code:
// Wave-specific macros foreach wa of local wave { // The 2010 wave has a different directory than the rest. if `wa' != 2010 { local data_`wa' "`path'/`wa'/Stata" } else local data_`wa' "`path'/`wa'/STATA/Methodologie10" foreach tab of local tables { foreach name of local `tab' { local wrong_files "`data_`wa''/`name'.dta" capture: confirm file `wrong_files' if !_rc { local `tab'`wa': dir "`data_`wa''" files "`name'.dta", respectcase local `tab'`wa': list clean `tab'`wa' di "`wrong_files'" di "``tab'`wa''" } else { continue } } } }
Code:
D:/XXXXX/inputs/working_data/2010/STATA/Methodologie10/menage.dta menage.dta D:/XXXXX/inputs/working_data/2010/STATA/Methodologie10/MENAGE.dta D:/XXXXXX/inputs/working_data/2010/STATA/Methodologie10/transmission.dta transmission.dta D:/XXXXXX/inputs/working_data/2010/STATA/Methodologie10/TRANSMISSION.dta D:/XXXXXX/inputs/working_data/2014/Stata/individu.dta D:/XXXXXXX/inputs/working_data/2014/Stata/INDIVIDU.dta INDIVIDU.dta
When I remove the respectcase option the code runs smoothly, but I don't want to do this because there might be Mac users among my working team.
Comment