fereprestige.blogg.se

Stata substring
Stata substring




stata substring

Stata will sort from smallest to largest on the first variable ( rh_feet1) and then by the second variable ( rh_inch1) within observations sharing the same value for the first variable. We can do this by first sorting the recruits from shortest to tallest using the sort command. Let’s say we want to look at the five shortest recruits. One way we could do this is to sort our data.

stata substring

We may also want to look at only the smallest or largest values when we list the data. Including the in 1/5 option tells Stata to list observations one through five. Given that there are 38851 observations, we do not want to do this. The list command by itself would list all of the observations. One option would be to open the data browser but, if you are like me and prefer to do everything from the command line, you can display several observations using the list command. These summary statistics are useful, but it also useful to take a look at a few individual observations to get a feel for the data. These help files are also very useful for learning the proper syntax for using a command. An easy way to do this is to simply type help commandname into the command line where commandname is the command you would like options for. If you are curious about what options you can add to a command, you can check the Stata help files for that command. Notice that to include an option for the command, we simply add a comma and then the appropriate option after the comma. If we would like a little more information, we can include the detailed option. Note that in this case we are told the number of observations for each variable as well as the mean, standard deviation, minimum and maximum.

stata substring

The second command, sum, is an abbreviation for the summarize command and provides basic descriptive statistics of the data. The other variable type you will typically encounter is a string. Numbers can be stored in several formats including byte, int, long, float, or double depending on how large the numbers get and how many digits they contain after the decimal place. In this case, all three variables contain numbers. The describe command tells you about the dataset, giving you information on the number of variables, the number of observations, and the data storage types for each variable. Variable name type format label variable label Now we can take a quick look at the data with a few basic commands. Finally, the use command opens our dataset. Note that you should change this to point to the directory where you saved the data files. The second command, cd, changes the current directory to the one containing our data file. If you do not issue the clear command and there is already data in memory that has changed since last being saved, Stata will give you an error message. The first command, clear, tells Stata to clear out any data that may currently be open. Users/jparman/Dropbox/courses/400-spring-18/stata-modules cd /Users/jparman/Dropbox/courses/400-spring-18/stata-modules/ In this case we simply open the data using the use command. The simplest scenario is a dataset already in Stata (.dta) format. How we load the data will depend on what format the data are in. Let’s try loading each dataset individually and then take a look at the data using the describe and summarize commands. UA-birth-states-and-dates containing birth states and birth dates for the recruits in CSV, Excel, and Stata formats.UA-wealth-long containing the 18 wealth data in CSV, Excel, and Stata formats.UA-race containing the race data in CSV, Excel, and Stata formats.UA-heights containing the height data in CSV, Excel, and Stata formats.

stata substring

I have created the following data files for use with this tutorial: In this tutorial, we will work with the data on the recruits’ heights, race, and wealth. This project gathered extensive data on Union Army recruits from a wide variety of sources. Let’s start by loading some data from the Union Army Data Project. 22 January 2018 Loading and Viewing a Stata Dataset






Stata substring