

There are two versions of log-files: one is Stata formatted (smcl) and another one is a text file. You can record all results that appear in the Results window in a log file. If you want to modify your do-file, type doedit filename. do is assumed when you enter do or doedit, so you don’t have to explicitly spell out your filename as do sample.do do sample is sufficient.

You can run the entire file by typingįilename can be any name. When you have finished typing your code, you can run it by selecting it and hitting the do button.

You can change the location of the current directory by the cd command, as in cd temp, for example (assuming that you have already created a folder called temp in Data directory). You can find the location of the current directory at the bottom left hand corner of the window (something like C:\Data in Windows). Stata looks for data and do-files in the current directory and save new data files there. Here you should make sure it is saved in the current directly. When you finish entering commands, save the do-file. To create a do-file, click on the do file button or type So we are just telling Stata what to do all in advance, instead of one by one. The way do-files work is very easy: we first create a file that contains all the commands that Stata should execute, and then tell Stata to execute them. If you don’t have a do-file when you want to repeat the same analysis again or modify your past analysis, you will have to type the same commands again. In addition, it is important to create do-files to keep track of what you did. This can be inconvenient once your commands become more elaborate. Without do-files, you have to type a command, wait for an execution, and then type another command. Do-files simply contain commands that you want Stata to execute. Problem sets usually require you to turn in your do-file. The Review window records your commands and the Variables window lists the variables in your data set (including the one that you created). You will type your commands in the Stata Command window.

#STATA HISTOGRAMS WINDOWS#
Then four windows will appear on your monitor. If you use Stata for Unix, type at the athena command prompt: You just have to double-click on the wstata (or stata) icon. If you run the same line of command without the comma, it will not work and the Review window will show "variable frequency not found.If you use Stata for Windows, starting Stata is straightforward.
#STATA HISTOGRAMS FULL#
For example, to make a frequency histogram with a title, the full command would become histogram variableX, frequency title(Histogram of VariableX) The comma tells Stata that what follows are options and not more variables. Basic elements like titles are added by appending the sub-command, and then specifying the details in parentheses. In addition, you can do a number of things to customize your histogram, both obvious things such as titles and less obvious things such as specifying how wide each bar is or at what number the histogram should start. Thus to create a basic frequency histogram of variable X, you would type histogram, frequency. Other options (typed in place of frequency) are percent (which puts percent out of a hundred on the y-axis) or fraction (which displays the data as a decimalized proportion). For a standard frequency histogram, you can add the frequency option. The default histogram graphs density along the y-axis, which is not typically what people want from a histogram. The histogram command takes a variety of arguments, the most important being the variable you want, which comes next. The command to create a histogram is histogram. When you execute a command using the user interface, Stata will display the syntax in the Results window, so this can be a good way to get a feel for how you would do things via the Command window.īoth tables and histograms are great ways to get a good look at your data over all trends and leanings, and can be useful precursors to analysis. If you are new to histograms in Stata, you might find it more intuitive to go to the Graphics menu and select Histogram. This is a good way to see all the options available and if you want a highly specific histogram, it may in fact be faster to specify your options in this manner.
