Hello Statalisters!
This may seem like a trivial question, but I want an efficient way to do my task and I can't seem to find it. In the following code:
What I wish to obtain are macro locals called `tab'`wa' (suppose `tab' contains country names and `wa' years) each containing the name of a single and unique file stored in several standardized folders. The reason I use macro locals and not filenames directly is because the actual database names are very different and there is no way to use a stub to use them (and I can't rename them neither), so using local macros is a useful way to do this. However, once I created all the desired `tab'`wa' local macros, when I use the command :
I get the following message:
= use "D:/XXXXX/Stata/"4572q.dta"", clear (edited to anonymize the results)
invalid '4572q.dta'
Which means the local `usa`wa'' has indeed double quotes that got 4572q.dta. is there a way I can ignore, or even better, remove these double quotes? Preferably I'd like something efficient and neat, so if it could suppress double quotes from the start rather than through commands like subinstr it would be perfect. Thank you all guys!
This may seem like a trivial question, but I want an efficient way to do my task and I can't seem to find it. In the following code:
Code:
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/methodology" 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 } else { continue } } } }
Code:
foreach wa of local wave { use "`data_`wa''/`usa`wa''", clear }
= use "D:/XXXXX/Stata/"4572q.dta"", clear (edited to anonymize the results)
invalid '4572q.dta'
Which means the local `usa`wa'' has indeed double quotes that got 4572q.dta. is there a way I can ignore, or even better, remove these double quotes? Preferably I'd like something efficient and neat, so if it could suppress double quotes from the start rather than through commands like subinstr it would be perfect. Thank you all guys!
Comment