View on GitHub

Stata Examples Regressions and Tables

Reusable Stata Code from Various Projects

Setting up GIT to pull from this repository

To view the STATA DO and html files, you can pull from the repository following instructions below. Alternatively, can click on Clone or Download and click Download Zip, which will download all files in Stata4Econ repository. Additionally, if you open one of the HTML files on github.com and would like to view it directly, append this to the beginning of the current HTML page’s full URL: http://htmlpreview.github.io/? (see https://github.com/htmlpreview/htmlpreview.github.com for more information on how)

You can set up your own github account if you would like. That is however not necessary for completing the following steps. Github allows us to host and share codes in the form of git repositories. git is a type of repository.

Installing and Open up Git:

  1. Download Git from here. Install the git program, follow on-screen instructions
  2. Search for the git bash program on your computer, open it. A window with black background opens up
  3. Type in: cd ~/, press enter, this takes your to the user directory on your computer. Type in: pwd, press enter, this shows you the path to your user directory, for me, it is for example:
      /c/Users/fan
    

First time clone:

This is for first time set-up. We clone a repository from github to your local drive.

  1. Create a directory under your user main for git repositories (only have to do this once)
      mkdir ~/GitRepos
    
  2. Enter into the directory, it is just a folder on your computer
      cd ~/GitRepos
    
  3. Clone our repository inside GitRepos. Note that this is just downloading a folder to your computer, but rather than clicking on web page, we are downloading via command-line.
      git clone https://github.com/FanWangEcon/Stata4Econ
    
  4. Now you can go to your folder and see our latest files. And you can open up matlab and set the directory to the one that contains Stata4Econ. For me that would be this folder, this is a git folder:
      /c/Users/fan/GitRepos/Stata4Econ
    

Updating existing Stata4Econ Git Repository:

I will be updating the files in our shared repository. You can pull from the shared repository to get the latest files.

The instructions below will eliminate any local changes you have made to the files and replace them with latest from our github repository. If you want to save your local changes, re-save the files that you have modified in another folder for yourself before you proceed with the codes below.

  1. Go to our Stata4Econ folder:
      cd ~/GitRepos/Stata4Econ
    
  2. First fetch all changes from origin (which we defined previously)
      git fetch origin
    
  3. Reset your local repository
      git reset --hard origin/master
    
  4. Pull from remote replace local
      git pull origin master