Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
readSHARE setup for Stata
// Instructions for setting up readSHARE in Stata
// What is readSHARE?
view browse ""
// 2.1. Load all the waves that you want to use in the same folder
* In other words, all folders containing the data for a SHARE wave should be found following the same path , for example under "C:/Users/JohnSmith/Documents/SHARE"
* Remember to extract the zip-files.
* We recommend you download all waves at once
// 2.2. Download readSHARE
ssc install readSHARE
// 2.3. Create the following macros
// Check that you do not have whitespace in your paths
global sData "C:/YOUR_DIRECTORY/" // NB! Insert your path here
global shareDesc "${sData}/shareDescStata"
global w1Dir "${sData}sharew1_rel7-1-0_ALL_datasets_stata/"
global w2Dir "${sData}sharew2_rel7-1-0_ALL_datasets_stata/"
global w3Dir "${sData}sharew3_rel7-1-0_ALL_datasets_stata/"
global w4Dir "${sData}sharew4_rel7-1-0_ALL_datasets_stata/"
global w5Dir "${sData}sharew5_rel7-1-0_ALL_datasets_stata/"
global w6Dir "${sData}sharew6_rel7-1-0_ALL_datasets_stata/"
global w7Dir "${sData}sharew7_rel7-1-1_ALL_datasets_stata/"
global w8Dir "${sData}sharew8_rel0-0-1_beta_ALL_datasets_stata/"
// NB! Run the above global macros every time you use readSHARE
*Alternatively you can copy the macros in the file. That way the macros are active upon startup of Stata
* file is created or located in your "personal" folder, the path of which can be found using the command
// you can check that your paths look reasonable by checking your paths using the following commands
// often missing "/"'s are causing trouble
di "${shareDesc}"
di "${sData}"
di "${w1Dir}" // etc.
// 2.4. Finally create a file containing the metainfo and save it
/ run the following two lines only once, and uncomment this after that
createSHAREDesc, sDir("${sData}")
cap n save "${shareDesc}", replace
// 2.5. Congratulate yourself for the good work when the following command opens the PH-module of wave 7
readSHARE *, w(7) mod(ph)
// 2.6. Also get familiar with the full functionalities of readSHARE
help addSHARE
help readSHARE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment