To do this, I thought I would add this chunk of code at the top of the file:
Code:
// Set OS variable for filesystem/directory control: values are: {linux, win} local os = "linux"
Code:
if "`os'" == "linux" { use "/mnt/DataResearch/DataStageData/CV_PATIENT_LABS.dta" } else { use "\\mrts-400-netapp\DataResearch\DataStageData\CV_PATIENT_LABS.dta" }
In python, I would just define a variable `dir_out` as such:
Code:
if os == 'linux': dir_out = '/mnt/DataResearch/DataStageData/' elif os == 'win': dir_out = '\\mrts-400-netapp\DataResearch\DataStageData\' else: pass
Code:
use = dir_out + "CV_PATIENT_LABS.dta"
A colleague suggested using the built-in Python interpreter to do this, but I can't see how that would be any better than having a ton of the `if-then-else` control sequences interspersed throughout the code.
Any suggestions would be most welcome.
0 Response to How to concatenate a local variable with a string in Stata
Post a Comment