Last active
October 23, 2023 16:01
-
-
Save larsvilhuber/afec296033d90ae21e1440f00095bfb2 to your computer and use it in GitHub Desktop.
Conditional Stata download
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this would be the directory to put data | |
global root : pwd | |
global data "$root/datadir" | |
cap mkdir "$data" | |
// now to the file in question | |
global nhtsfile "nhts-ascii.zip" | |
capture confirm file "$data/$nhtsfile" | |
if _rc != 0 { | |
// what to do when file does NOT exist | |
copy https://nhts.ornl.gov/2009/download/Ascii.zip "$data/$nhtsfile" | |
} | |
// might want to also test for a "trigger" file | |
// to not unnecessarily unzip again | |
cd "$data" // Stata cannot unzip into a different directory, so we have to | |
// deviate from our rule to never use "cd" | |
unzipfile "$nhtsfile" | |
cd "$root" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment