You are on page 1of 18

Introduction: STATA on JupyterHub

1. Open your browser and navigate to:


https://stdwk1. hiebs.hku.hk:8055/

If you have NOT yet sign-up, please refer to the sign-up guide.

2. Enter your username and password for JuypterHub and then click on “Sign In”
3. The “Launcher” page would have appeared. If not, you can click on “+” on the left-hand side panel to open one.

Click on “+” to
open a new
Launcher
4. There are two STATA icons on the Launcher – the 1st one is under the “Notebook” category while the other is under “Console”. In other words, the
1st one will be running in Jupyter Notebook and the 2nd one will be running in a terminal mode (text mode).
5. Click on “STATA” under the “Console” category to open Stata in terminal mode. Note that the page is called “Console 1” to notify that it is in
terminal mode. Please note that STATA is connected and in idle mode waiting for your inputs in the bottom notification area.
6. You can type in any STATA command in the input area OR upload any file to your home folder

Upload files from PC

Home Folder on server

Input area
7. We use the automobile dataset that comes with STATA for illustration. Type in “sysuse auto” in the input area and then press “Shift + Enter” to
execute the command

Type in “sysuse auto” → press “Shift +


Enter” to execute
8. After the command is submitted, you can find the response/result in the console

A number here
means the
command is
successfully
executed

“Stata| Idle” means STATA


is waiting for commands
9. You can type in any STATA commands, e.g. describe, sum etc.
10. However, for some special commands, you need to add % before the command. Please find below a summary of those commands:

STATA Command STATA Command


(Original) (for Jupyterhub)
browse %browse
head %head
tail %tail
delimit %delimit
help %help

11. To read in data, you need to upload the data file first. Remember NOT to include any space or special characters, e.g. &, % etc., in the filename.
Click on the upload button and choose your file to upload.
12. You can create a new folder by right-clicking your mouse when pointing to the empty area on the left-hand side panel. Click on the folder to move
inside.
13. Enter command in the input area to read the file into STATA: e.g. “import excel “imfdata.xls”, sheet(“Sheet1”) firstrow” → “shift”+”Enter”.

Note: If you encounter a problem saying that file imfdata.xls not found, you need to change the folder to /data/ by the following command:

cd ~/data

You can check the current folder by the following command:

pwd
14. You can continue to work on the dataset
15. However, you cannot save your inputs or result in terminal mode. To save your work, you need to use STATA in Jupyter Notebook. From Launcher,
click on the 1st STATA icon.

Can save your commands and


result as Jupyter notebook

Can NOT save the


command as any file
16. You can work inside Jupyter Notebook with your STATA command
17. You can read in your data and plot your graph and download it as pdf file

Download and Print


button appear when
pointing on the graph
18. If you want to save your graph in other formats, you need to export the graph using STATA command. Then, you can download the graphic file
directly to your PC.

Graphic file created in


current folder --
download by highlight
the file and right click
your mouse →
download
19. If you have uploaded your do file (OR you can create it on the server by working on a text file), you can execute the following command to submit
your do file: do filename.do. You can double-click on the do file and edit it online.
20. You can press “Ctrl+S” to save the notebook OR click on File→ Save Notebook and then rename your file

You might also like