stata

How to get Stata to report zeroes in tabulate

岁酱吖の 提交于 2019-12-22 10:34:15
问题 I'm trying to use the tabulate command in Stata to create a time series of frequencies. The problem arises when I try to combine the output of tabulate after running through each date. tabulate will not include 0 as an entry when no observation exists for a value of the variable in question. For instance, if I wanted to count the 10, 11 and 12 year olds in a class over a three-year period Stata might output (8) if only one of the groups were represented and thus we don't know which group the

Importing foreign languages from csv file to Stata

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 10:15:51
问题 I am using Stata 12. I have encountered the following problems. I am importing a bunch of .csv files to Stata using the insheet command. The datasets may conclude Russian, Croatian, Turkish, etc. I think they are encoded in "UTF-8". In .csv files, they are correct. After I imported them into Stata, the original strings are incorrect and become the strange characters. Would you please help me with that? Does Stat-Transfer can solve the problems? Does it support .csv format? For example, the

Generate percent change between annual observations in Stata?

安稳与你 提交于 2019-12-22 10:08:28
问题 How do I use the gen or egen commands to generate the percent change between observations for different years in Stata? For example, I have observations for 1990 through 2010, each with a different value for expenditures, and I'm trying to generate a new observation with the percent change from 1990-1991, 1991-1992, etc. 回答1: // Here's an example with another measure of growth: clear set obs 100 gen year = _n + 1959 gen expenditure = _n^(1/3) + runiform() line expenditure year, yti("Synthetic

Break a command into several lines in do-file in Stata

半腔热情 提交于 2019-12-22 03:55:34
问题 I want to run the keep command in a do-file in Stata 12: keep a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 What I want is to do the following: keep {a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4} I know the {} brackets don't do the trick but I'm looking for the command that does it. Using #delimiter ; does not work either. I want to do this because subgroups of variables have a relation among themselves (which I intended to signal above by using a , b and c ) and I want to have that clear in my code

sending code from vim to stata

醉酒当歌 提交于 2019-12-21 10:16:13
问题 I have been using Vim to write Stata scripts in Windows for a while now at the university. I am learning R at the moment, and I want to switch completely to Linux as my OS (I've recently switched to Ubuntu on my laptop). R works fine with Vim in both Windows and Linux, however I still need to use Stata sometimes. In Windows I have been using a simple AutoIt script provided by a Stata user to send lines / the whole file to stata for evaluation. This script doesnt work in Linux. This is what

Stata command line arguments in batch mode

孤人 提交于 2019-12-21 05:06:50
问题 A helpful FAQ from Stata describes that arguments can be passed to do files. My do file looks like this: * program.do : Program to fetch information from main dataset args inname outname save `outname', emptyok // file to hold results insheet using `inname', comma clear names case // a bunch of processing save `outname', replace According to the FAQ, this script can be run using do filename.csv result.dta . When I run this command from within Stata, everything works fine. The program is long,

Two stage least square in R

家住魔仙堡 提交于 2019-12-20 14:19:14
问题 I want to run a two stage probit least square regression in R. Does anyone know how to do this? Is there any package out there? I know it's possible to do it using Stata, so I imagine it's possible to do it with R. 回答1: You might want to be more specific when you say 'two-stage-probit-least-squares'. Since you refer to a Stata program that implements this I am guessing you are talking about the CDSIMEQ package, which implements the Amemiya (1978) procedure for the Heckit model (a.k.a

Frequency weighting in R, comparing results with Stata

拜拜、爱过 提交于 2019-12-20 10:29:45
问题 I'm trying to analyze data from the University of Minnesota IPUMS dataset for the 1990 US census in R . I'm using the survey package because the data is weighted. Just taking the household data (and ignoring the person variables to keep things simple), I am attempting to calculate the mean of hhincome (household income). To do this I created a survey design object using the svydesign() function with the following code: > require(foreign) > ipums.household <- read.dta("/path/to/stata_export

Using Stata Variable Labels in R

旧时模样 提交于 2019-12-20 09:37:39
问题 I have a bunch of Stata .dta files that I would like to use in R. My problem is that the variable names are not helpful to me as they are like "q0100," "q0565," "q0500," and "q0202." However, they are labelled like "psu," "number of pregnant," "head of household," and "waypoint." I would like to be able to grab the labels ("psu," "waypoint," etc. . .) and use them as my variable/column names as those will be easier for me to work with. Is there a way to do this, either preferably in R, or

How to include AIC in table after margins postestimation results

拈花ヽ惹草 提交于 2019-12-20 06:34:35
问题 I have a GLM model, which I estimate in Stata. The coefficients of interest are the marginal effects, which I get with margins command. However, the postestimation table does not include summary statistics like AIC, which I would like to have there. I have tried this by writing an auxiliary program getAIC : program getAIC estat ic matrix list r(S) matrix S = r(S) scalar aic = S[1,5] end The estimation would then proceed like this: qui glm y x, fa(bin) link(probit) getAIC qui margins, dydx(x)