You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains 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
* simply type "share" before use,merge and append commands
* replace path with "module wave", e.g. "dn 9", see examples below
// Setup:
* copy-paste the share-programme in the beginning of your do-file (or in profile.do so that the programme is loaded automatically when you launch stata)
* check the lines with "NB!" below. You will need to make some minor changes to the code in order to update the directories, release numbers etc.
//Credit:
* Daniel Klein https://www.statalist.org/forums/member/103-daniel-klein
* For more info, please visit the original post https://www.statalist.org/forums/forum/general-stata-discussion/general/1744123-simple-user-defined-function-program-with-custom-input-and-output
cap nois program drop share
program share
version 18
syntax anything [ using/ ] [ if ] [ in ] [ , * ]
local mydirectory ="C:\D\SHARE\public" //"C:/PATH_TO_YOUR_DIRECTORY" // NB! update with your path (every wave will need to be in its own folder)
if ("`using'" == "") {
/*
<module> and <wave> are part of <anything>
More specifically, we assume that <anything> is
<command> "<module> <wave>"
as in, e.g.,
use "<module> <wave>"
(double quotes optional)
*/
gettoken command anything : anything
gettoken module anything : anything
gettoken wave anything : anything
if (`"`anything'"' != "") error 198
local anything `command'
local using `module' `wave'
}
else local the_word_using "using"
gettoken module wave_void : using
gettoken wave void : wave_void
if ("`void'" != "") error 198
capture local wave =string(`wave')
*confirm integer number `wave'
*di "test1"
// NB! Make sure that releases and folder names match with yours (do not change any names after downloading it from the data portal)
local release = cond("`wave'"=="9", "rel0", "rel8-0-0") // update release in here
local using "`mydirectory'/sharew`wave'_`release'_ALL_datasets_stata"
local using "`using'/sharew`wave'_`release'_`module'.dta"