I am trying to generate a dummy variable that = 1 if at least two or more (out of seven) dummy variables also == 1. Could anybody tell me an efficient way of doing this? --------------Solutions------------- Let's suppose that the indicator variables
A code I am running uses svy:mean and there is NO subpop command used. My issue is that is that for certain variables, it renames some of the values of the variable to _subpop_1, etc. but others are still in their original format. For example, I have
(Stata/MP 13.1) Hi, I am working with a set of massive data sets that takes an extremely long time to load. I am currently looping through all the data sets to load them each time. Is it possible to just tell Stata to load in the first 5 observations
I am new to Stata and I will be grateful if someone can help me figuring out how to add additional labels in my bar chart. I have frequencies for 5 categories (let's say Apple, Orange, Banana, Grape, Lemon) and would like to make a bar chart comparin
Is there a way to stop the execution of a do-file in Stata when an error occurs? The issue is that the do-file contains commands that could work despite the error. --------------Solutions------------- Stata's view is that any error will result in an
I have a data set which looks as follows: delta taubar 0 1.5 -0.223 2 3 6.5 0.334 2 11 7 2.123 1.5 delta takes different values corresponding to taubar. However, I would like to create a variable which takes the mean of delta for each value of taubar
I need to generate a new variable that is a standardized value of another variable but by a group (SAT scores by year). I calculated it using the following code: egen mean_sat = mean(sat), by(year) egen sd_sat = sd(sat), by(year) gen std_dat = (sat -
I need to generate a variable representing household income. I have each individual's income information and have identified the head (head == 1) and spouse (spouse == 1). Now I decide to define the household income as head's income plus their spouse
I would like to make a summary statistics table using esttab from the estout package on SSC. I can make the table just fine, but I would like to add a column that counts the number of non-missing observations for each variable. That is, some variable
I am trying to output the mean and sd for continuous and factor vars using the following code. sysuse auto,clear estpost sum price length foreign bn.rep78,listwise esttab, cells("mean sd min max") nomtitle nonumber However, I got the following error.
I have a panel dataset (country-year) in Stata. For instance I have GDP in 1990,1991,..2010 for many countries. I want to define a variable "GDP in 2006" which exists for all years and contains the 2006 value of GDP. The way I am doing it now works b
I am using Stata and have panel data with two periods, t1 and t2. I also have a unique identifier that is constant across periods if the person has responded over both periods. For example, if person001 completes survey in both t1 and t2, answers to
I want to use Mata to create a block diagonal matrix. There is an example in the documentation for three matrices: blockdiag(Z1, blockdiag(Z2,Z3)) It's not clear to me if that can be extended to more matrices: blockdiag(Z1, blockdiag(Z2, blockdiag(Z3
I am trying to run the example provided in the help file of user written command "tpm" (ssc install tpm), but it is giving the error invalid syntax. webuse womenwk, clear replace wage = 0 if wage==. set trace on tpm wage educ age married children, f(
I am using population-level American Community Survey data to look at factors that affect income from self-employment, with a primary interest in the female population. I want to create a variable to measure "husband's income." There is a variable pi
I recently bought Stata 13.1 for my Ubuntu 13.10. And I noticed a few problems in it: 1) If I use Stata as a non-root or non-super user, then the menu bar of Stata will be on the top bar of Ubuntu desktop, and if you open a window from menu bar, the
If we put "*" in the beginning of the line then Stata is supposed to ignore the line. But I find again and again that if I don't put semicolon at the end of the comment line, the program gives me spoiled estimation result. Why is this? Isn't Stata su
I am trying to run a program inside a loop, but I am getting -Break-- r(1); Here is my script: clear all forvalues i=1/5{ sysuse auto if rep78==`i' capture program drop testpro program define testpro,eclass preserve tabstat price mpg headroom,stat(me
I have a data.table with 11 variables and 200,000+ rows. I am trying to find the unique identifier (in other words, key) in this data.table. I am looking for something like isid in Stata, which checks whether the specified variables uniquely identify
I would like to use esttab (ssc install estout) to generate summary statistics by group with columns for the mean difference and significance. It is easy enough to generate these as two separate tables with estpost, summarize, and ttest, and combine