I have a lot of scripts (.do files) in different folders, which are frequently moved around. I would like to have Stata detect where the script is, and use that as a pwd (working directory). I know people that have this functionality seemingly by default (the pwd is changed to the script location when the script is run), but we cannot figure out why I am not so lucky. It is a bit tedious always having a "cd" line at the top of my scripts, and having to change this line to reflect the current directory. I'm using Stata 12 with Windows 7 Professional.
Change Working Directory (pwd) to Script Location in Stata 12
2.3k Views Asked by Tahlor At
2
There are 2 best solutions below
0
Matthew
On
You can use Sublime text.
https://sublime.wbond.net/packages/Stata%20Enhanced
When you build the do file (or a selection) using sublime text, the filepath of the do file automatically becomes the current directory.
Related Questions in DIRECTORY
- I cant access file directory with PHP local host on XAMPP. it just shows one of the files I have in my visual studio code
- PHP string variable to multiple rows in table sql insert
- Android - Why my app picks values on default folder (instead XXHDPI)
- Use htaccess to add subdirectory to url while displaying base url
- Dockerfile and package-json are in different folders
- VS2022 C++ empty directory for audio file. CMake; SFML
- Visual Studio Error: The system cannot find the file specified
- Email from SharePoint: "Heads up! We noticed that you recently deleted a large number of files from a site" but the user doesn't deleting anything
- Duplicate folder into new folder one level up in the directionary
- Shapefiles not showing up in assigned directory in R - says it exists but can't find it
- Recursively calculate SHA256 sum of all files in directory using OpenSSL
- $WinREAgent folder keeps to automatically appear
- thunderbird local archive folder missing
- Python folder path string escape character error
- Switch r settings to not have to create directory when saving files into new subfolders
Related Questions in STATA
- How to only estimate neonatal mortality using syncmrates in Stata?
- Stata + ODBC driver requires login too often
- The \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} problem (Stata - Beamer)
- i have run the pvar model, but i am not able to run the irf plot, it is giving me error that it is not positive semi definite
- In Stata: how to evaluate a string stored in a macro as a variable name?
- r(101): trying to advance in my thesis and I have encountered this error while doing a loop
- Stata interaction term is zero or there is no number
- Vietnamese font
- Stata foreach loop says tabulate is not a valid command name?
- using stata svy subpopulation option for running regression
- How to export means from ttest
- Using encode command to convert string variable to numeric
- How to do calculation using local macros
- How to transform a Dofile to PDF
- Double selection lasso in and NA's handling
Related Questions in WORKING-DIRECTORY
- How to make Python script use a designated directory as source for imports (from within the script)?
- How to get the path of a file without normalisation in ruby?
- How to set the location that JavaCompiler executes from?
- Why my program can't find the file when opening .txt files?
- Read image from a file using OpenCV
- the working directory options does not exist in scheme on Xcode 15
- Running same Java Spring Boot Application in different Working Directories
- Issue with Reading a File Using Relative Path in Python
- What is parent directory of a process?
- create a folder out of working folder without use of double period with Dir.mkdir
- How do I find and remove a setting value in Visual Studio Code?
- Can I get the current console filepath from which a script was invoked from within said script?
- Set working directory for Visual Studio 2022 CMake projects with Ninja generator
- Upscaling with Realesrgan
- Why doesn't `console.log(Deno.cwd())` print anything in the debugger?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It looks to me like something similar is answered in this question:
Paths to do-file in Stata
What it seems like you could do is keep an MS Excel file that somehow tracks the location of all your scripts, and then use that to generate a simple high-level do-file that calls all your programs (although this may not be how your scripts work). If your folder locations are changing I am not sure how you can completely avoid updating at least some lines of code when something gets moved around. This would at least centralize the necessary updates into one place.