Splitting strings

In -destring- complication, Anup asked how to split a string variable. In his case, he has a variable of the form 28-18-0018-02183100-02-O-B where 28 represents state code, 18 represents districts code, 0018 represents subdistricts code and 02183100 represents village code. His problem is how to extract the state, districts, etc. codes separately from the variable and label all the […]

Splitting strings

In -destring- complication, Anup asked how to split a string variable. In his case, he has a variable of the form 28-18-0018-02183100-02-O-B where 28 represents state code, 18 represents districts code, 0018 represents subdistricts code and 02183100 represents village code. His problem is how to extract the state, districts, etc. codes separately from the variable and label all the […]

Rolling standard deviations and missing observations

In And we’re rolling, rolling; rolling on the river, Hasan asked how he could “keep only those values that were calculated using at least 3 observations” after he calculated the 4 period rolling standard deviation of a set of observations. One solution is to tag the periods when the missing observations within the window (in […]

Rolling standard deviations and missing observations

In And we’re rolling, rolling; rolling on the river, Hasan asked how he could “keep only those values that were calculated using at least 3 observations” after he calculated the 4 period rolling standard deviation of a set of observations. One solution is to tag the periods when the missing observations within the window (in […]

Blah-blah-blah about do-files

Data analysis in Stata may be carried out by interactive mode using the Command window, by using the drop down menu, or by executing a set of Stata commands written in a do-file. It is most likely that you will be using a combination of these rather than using one method exclusively. Making use of […]

Blah-blah-blah about do-files

Data analysis in Stata may be carried out by interactive mode using the Command window, by using the drop down menu, or by executing a set of Stata commands written in a do-file. It is most likely that you will be using a combination of these rather than using one method exclusively. Making use of […]

Blah-blah-blah about do-files

Data analysis in Stata may be carried out by interactive mode using the Command window, by using the drop down menu, or by executing a set of Stata commands written in a do-file. It is most likely that you will be using a combination of these rather than using one method exclusively. Making use of […]

Clever way to dummy

Relational operators (>, <. >=, <=, ==, !=) evaluate to 1 if the expression is true and 0 if false. Given this definition, a dummy variable can be created using, for example: gen newvar = (oldvar <= somethreshold) if !missing(oldvar) Instead of the longer alternative: gen newvar = 1 if oldvar <= somethreshold replace newvar = […]

Clever way to dummy

Relational operators (>, <. >=, <=, ==, !=) evaluate to 1 if the expression is true and 0 if false. Given this definition, a dummy variable can be created using, for example: gen newvar = (oldvar <= somethreshold) if !missing(oldvar) Instead of the longer alternative: gen newvar = 1 if oldvar <= somethreshold replace newvar = […]

Clever way to dummy

Relational operators (>, <. >=, <=, ==, !=) evaluate to 1 if the expression is true and 0 if false. Given this definition, a dummy variable can be created using, for example: gen newvar = (oldvar <= somethreshold) if !missing(oldvar) Instead of the longer alternative: gen newvar = 1 if oldvar <= somethreshold replace newvar = […]