

B1title() is used to label the x-axis of bar charts instead of xtitle(). The variable on the x-axis is specified in the over() option. The count statistic is specified in parenthesis to make a bar chart of the count of observations. The bar chart is usually used to plot summary statistics on the y-axis such as the number of observations for each category of another variable. Scatter deptime dayofweek, msymbol(+) msize(huge) mcolor(maroon) xlabel(1(1)7) plotregion(margin(10 10 2 2)) The plotregion() is used to specify the margin between the plot region and the axes. The xlabel() is specify the ticks on the x-axis. The msymbol(), msize() and mcolor() options can be used to specify the shape, size and color of each point on the scatterplot. Hist deptime, normal bin(30) color(ltblue) lcolor(white) xtitle(Departure Time) Color() and lcolor() are used to specify the color of the bin and the border around the bin. Bin() allows the user to specify the number of bins. The normal option adds a normal curve on the histogram. Ytitle() is used to specify the label of the y-axis. Xtitle() is used to specify the label of the x-axis. Some options can be applied for all or most graphing commands. The list of options possible can be found in the help file of each command. There are many options that can be added to modify all graphs. The hist, scatter and graph bar commands can be used to make a histogram, a scatterplot and a bar chart respectively. For example, we can get the summary statistics of flight distance for each day of the week.
#Rename x axis labels stata code
Two equal signs are used for the equal to condition.īysort can be used to run a line of code for every category of a second variable.

For example, we can get the summary statistics of flight distance for flights that took place on Mondays only using the dayofweek variable and setting it equal to 1 which represents Monday. We can add conditions to a line of code using the if qualifier. It gives summary statistics of numeric variables. The cell, row and col options display the cell, row and column percentages. The m option is used to display the number of missing values for the specified variables. List originstate deptime depdelay in 1000/1005 It allows users to specify the variables and observations to print. List can be used to print data values in the results window. Codebook gives a frequency table for character variables, basic statistics (mean, std dev etc) for numeric variables and the number of missing observations for both types of variables. You can check the number of rows and the number of observations in the properties window.ĭescribe enumerates the list variables, their data type and their labels. Once you import the dataset, the variables are listed in the variables window. Every time you import a dataset, it is good practice to add the clear option to clear any dataset that is loaded in memory. The use command can be used to import a Stata dataset. You are advised to save all the datasets from this tutorial in the same folder and to make this folder the working directory using the cd command.ĭir and ls both show the content of the current directory. Use cd to change the working directory to the location of your datasets. The working directory is the home directory that Stata works from by default. Help enter_command_here returns the help file for a specific commandĬlear removes the dataset that is currently loaded in memory so that you can import a new dataset

Search enter_topic_here returns the list of commands associated with a topic The results will always appear in the results window. Once you type your code in the do-file, you can run it by highlighting the line of code and clicking on the execute icon (the play button) in the top-right corner of the do-file window. To open a do-file editor, go to the File menu, then go to New and select Do-file. Or you can type Stata code in the do-file editor. You can type Stata code in the command window and submit the code by hitting the ENTER/return key. You can use point-and-click to execute tasks using the dialogs from the Data, Graphics and Statistics menus. There are three ways to run tasks in Stata. If you need assistance, fill out the support request form. The link to the recording of this workshop can be found here. The other two datasets used are fabricated datasets created for the purpose of this guide. It contains the US domestic flights in January 2020. The main dataset used is the flights dataset. This guide has been created using Stata IC version 16.1.
