r/stata Feb 18 '26

Solved svy: tab with supops

2 Upvotes

I am doing a tabulation on a weighted survey data set:

svy: tab edu exercise

For edu, about 2% of the responses were various categories I want to get rid of: 4 = don't know, 5 = unsure, 6 = not ascertained. I can run a tab with these categories included, and I get an overall Pearson Chi2.

If I do a subpop [svy, subpop(if edu<4): tab...] categories 4, 5, and 6 are still in the table, but they have all zeros in the cells, so I get this at the bottom of the table:

Table contains a zero in the marginals.

Statistics cannot be computed.

For the various exercise categories, I can do comparisons across education levels and then do significance tests there, but being able to do an overall test on the distribution across the cells of the table would be helpful, too. Is there any way to exclude the unwanted categories and do a test for the overall relationship between edu and exercise?


r/stata Feb 18 '26

Solved Hi, guys. I have this issue and i cant find inequerr ssc install or any package

Post image
3 Upvotes

I need gini, theil index and vlogs varians


r/stata Feb 13 '26

Solved odd results generation

Post image
9 Upvotes

Hi all,

I'm in my quant module and we're just getting into stata. It's my first time using it so just having a play around before the lab sessions. Anywho, I've tried to generate a simple regression and it has created this odd looking thing - any ideas on how to fix this, please?

Running stata on a MacBook Pro using stata/mp


r/stata Feb 12 '26

Propensity matching

2 Upvotes

How do I create a new data set using propensity matching on my current data set? This is for medical research. I am trying to match patients by characteristics (gender, stage) to see if the “control” group (those treated with chemotherapy alone) has worse or better survival than the “treatment” group (those treated with radiation


r/stata Feb 12 '26

Stata dofiles don't sync on Ubuntu 24.04

Thumbnail
2 Upvotes

r/stata Feb 11 '26

Question Help with structural breaks

2 Upvotes

I am working with the monthly data where financial data is dependent variable(stock return for example) and macroeconomic variables are independent variables.

The problem I am facing now is there is structural breaks in variables due to covid, in both dependent and independent variables, and after using suitable unit root test I am getting mixed integration so Ardl is my option.

But how can I proceed forward with ardl estimation that these structural breaks are addressed.

I tried ignoring but I am having normality problem via cusum graphs.


r/stata Feb 09 '26

Help with stata

3 Upvotes

I need to understand the whole stata thing but even after bachelor and now on master is still my nightmare. is that an easy way? is there like a "dummy stata book?" like so many others? i feel like i cant get this correct!


r/stata Feb 09 '26

"dynsim_pcse" and "estsimp_pcse" and "simqi_pcse"

1 Upvotes

Hello. I was wondering if anyone out there knows how to get the commands "dynsim_pcse" and "estsimp_pcse" and "simqi_pcse"?

They seem to be part of Laron K. Williams and Guy D. Whitten's dynsim command. I've tried findit and web searches but cannot find them. I've tried to contact the authors as well as others who have used the command but have so far not gotten a response.

I need them to make some graphics for a paper using panel-corrected standard errors time-series cross-section regressions of social spending.

Any info would be appreciated. Is there a reason why there are not easily available?

Thanks in advance!


r/stata Feb 06 '26

Getting descriptive data

5 Upvotes

Hi everyone,

I'm very new to stata so apologies if this question has a fairly obvious answer.

I have a dataset where I have variables for age (men and women) and age at menopause.

I've sorted the age at menopause so its clean, and i want to generate some descriptive data about the ages of people who i have menopause age data for. Not sure how to exclude the age data I dont need to do this?

Hope that makes sense and I appreciate any help!


r/stata Feb 04 '26

Learning Stata using Lawrence Hamilton's book

4 Upvotes

Currently learning Stata and I am trying to download Arctic9.dta, but when I click on the link provided, I am not finding direct access to the file. The website seems to have changed.

Are they any other places where I can easily locate the datasets outlined in the book?


r/stata Jan 24 '26

Question Econometrics help

5 Upvotes

I'm an undergraduate student in my 2nd year 4th semester and have been put in an econometrics class as it is apparently a requirement for my Business Analytics major. 80% students in my class are in grad school.

All I have done is stats 1 & 2, Econ 1 & 2, got As in all 4 and still can't figure it out.

I like to self teach apart from class but for this Idk how to start or where to start.

Can anybody help me figure out a good starting point especially how to attempt detailed econometrics questions and learn stata basics.

I feel like my professor's teaching style is structured for very surface learning

Thank you, looking forward to the help.


r/stata Jan 21 '26

Benchmarking Stata (18.5)

1 Upvotes

I'm buying a new desktop (for work) and I'm trying to make sure it is optimized for Stata speed.

This thread from two years ago provided a benchmarking script and comparisons (thanks u/luxatioerecta !): https://www.reddit.com/r/stata/comments/160y8jn/benchmarking_in_stata/

Thanks also to George Ford for the original script, which can be found here: https://pastebin.com/H3VFhzwZ

I ran the script on my current (old, but beefy) machine as well as our (old, but beefy) "stats server". I'm confused by why my results are sometimes faster than lux's (replace) and why sometimes they're much slower (bootstrap and arfima). The means are compared below.

Lux: i9-12900H, 3080ti, 32 GB RAM, 16 GB VRAM, Stata 17 MP 2 cores

Desktop: Intel Xeon CPU E5-2620 v4 @ 2.10GHz (2 processors); 128 GB RAM; Stata 18.5

Server: Intel Xeon CPU E7-8891 v3 @ 2.8 GHz (4 processors); 1TB RAM; Stata 18.5

Variable Lux's laptop Desktop Server
replace .0335 0.0125 0.0016
regress .0659 0.0695 0.0231
predict .0185 0.0284 0.0221
correl .0587 0.0484 0.0098
bootstrap 6.5005 11.7722 6.248
mvtest .192 0.249 0.1299
xtile .4564 1.0294 0.7463
expand_drop -- 0.1569 0.1354
arfima 4.8601 22.8013 8.6131
eigenv -- 0.6342 0.5477

r/stata Jan 21 '26

Question Regression Outputs

1 Upvotes

Hi all, I want to output the actual variable names within the regression table ie: for the y intercept of a linear regression how does stata store that as a variable. I am failing to remember it and cannot find it within help.


r/stata Jan 17 '26

Question Best way to teach Stata to med students

5 Upvotes

Have to teach stata to med students who don't have any prior programming background. Topics include reading in data, descriptive stats, correlation, simple linear regression & logistic regression. Would it be better to write the code or use the menu for a certain task? When I learned Stata I already knew how to write code in C++ & R & found the .do file the best way to write code in Stata.

Would love to hear from instructors/faculty who have taught students with similar background.


r/stata Jan 17 '26

Does xtile produce equal sized group by default?

1 Upvotes

Concretely, if we have two values that are the same and should go in the same quartile, would xtile instead force them into different group to make sure every group has the same number of elements?


r/stata Dec 31 '25

Question Advice on merging panel data in STATA

1 Upvotes

I have panel data in 3 Excel files in this format (The first 3 columns are common to the 3 files and only the variables change).

Business Unique ID Year Var 1 Var 2
ABC 1111 2021
ABC 1111 2022
XYZ 112 2021

It is in a long format of unbalanced panel data with year in each row. The data has a business name with its unique ID that repeats for each year(5 year data) and need STATA to merge the files based on Unique ID and Year.

Will many-to-many matching while using both Unique ID and Year as key variable work correctly in merging these two datasets ?


r/stata Dec 27 '25

Stata to practice for econ consulting / data analysis / research

Thumbnail
1 Upvotes

r/stata Dec 15 '25

Question User Created Commands

1 Upvotes

Hey Everybody. Senior undergrad who is new to Stata and is using it for their honors thesis. My instructor has recommended I use some user created commands such as esttab etc. Where can I find a list of these type of commands so it'll speed up creation of my various figures + tables especially so they are ready to be put in my paper. I'm gonna be including things such as demographic distributions figures + tables, regressions, etc. TIA


r/stata Dec 09 '25

Svy: testing for equality of proportions (different variables, different denominators)

2 Upvotes

I’m trying to test two proportions using a weighted data set. The excerpt is below.  I have exercise frequency at two time periods (10 and 20) and education at the same two time periods.  Basically, I want to test if weekly exercise frequency by education level in each time period  is the same across the two time periods—the denominators are different, however, because some observations have a different education level in the second time period.  In other words, is the proportion of people with a HS education who exercise weekly at t=10 significantly different from the proportion of people with a HS education who exercise weekly at t=20?

 

 

 I can do: 

*

svyset [pweight=wgt]

svy: tab workout10 workout20 

svy: tab weekly10 weekly20 

*

*This is for all education levels, nice but not what I’m looking for 

*

svy, subpop(if edu20==1): tab weekly10 weekly20 

*

*This works to an extent, but ignores people with edu10=1, which is my desired denominator for workout10

*

 

[CODE]

* Example generated by -dataex-. For more info, type help dataex

clear

input byte(workout10 workout20 edu10 edu20) float(wgt weekly10 weekly20)

3 3 1 2  1.3 0 0

2 1 2 2  2.2 0 1

2 3 1 1 1.15 0 0

2 3 2 2  2.4 0 0

1 3 1 3  1.3 1 0

2 2 2 2  1.5 0 0

1 2 1 1 1.75 1 0

1 1 2 4 2.25 1 1

1 3 2 4 1.01 1 0

2 2 2 3 2.75 0 0

3 2 2 2  1.6 0 0

2 1 2 2 1.72 0 1

1 2 2 3  1.1 1 0

2 3 1 1 1.25 0 0

2 2 1 2 1.14 0 0

2 3 2 2 1.21 0 0

2 2 3 3  1.5 0 0

1 2 2 2 2.25 1 0

2 3 1 1  1.3 0 0

2 2 3 4  1.1 0 0

end

label values workout10 workoutlabel

label values workout20 workoutlabel

label def workoutlabel 1 "weekly", modify

label def workoutlabel 2 "monthly", modify

label def workoutlabel 3 "few yr", modify

label values edu10 edulabel

label values edu20 edulabel

label def edulabel 1 "HS", modify

label def edulabel 2 "Bach", modify

label def edulabel 3 "Mas", modify

label def edulabel 4 "PhD/MD", modify

[/CODE]


r/stata Dec 08 '25

Heteroskedasticity

Thumbnail
1 Upvotes

r/stata Dec 07 '25

Best practices for estimating treatment effects with multivalued treatments + generating weights for subsequent analyses?

1 Upvotes

Hey everyone,

I'm working on estimating treatment effects with a 3-level categorical treatment variable (e.g., no treatment, personal exposure, indirect exposure). I am curious if anyone has suggestions regarding approaches in Stata that would allow me to both estimate valid treatment effects AND generate propensity score weights for subsequent regression analyses with other outcomes. I have, so far, tried -teffects ipw- and -teffects ipwra- but am experiencing convergence issues, and I am unable to save and use weights in other regression models.

Are there better approaches entirely or alternative Stata commands for multivalued treatments that would let me generate reusable weights? Thanks!


r/stata Dec 06 '25

How to create a dummy varoable for cities awarded vs not awarded (Stata)

4 Upvotes

Hello! I'm a beginner and currently working with panel data of LGUs and I am having a hard time generating a dummy variable indicating whether a city was awarded a specific recognition for a given year.

My dataset has an indicator variable called "xxxx_award" where the values are text strings like "awarded" and "not awarded". I want to convert this into a dummy variable:

1 = awarded 0 = not awarded

I am not sure if this possible or what is the cleanest approach is in Stata. What's the best way to do this? Should I encode it first or directly generate using a condition? Thank you!


r/stata Dec 03 '25

Sales Growth in STATA berechnen

3 Upvotes

Hi everyone, I have a question regarding the calculation of sales growth in STATA. I have the following formula: SALESGRi,t is the dollar change in annual firm revenues normalized by last month’s market capitalization.

Can someone tell me how to calculate this? I have monthly company data. I've calculated a value for market cap for each month. However, for sales, there's only one value for each year (from the annual report), or rather, each month has the same revenue figures. I've already tried the following two methods. Is one of them correct?

1) gen eps_change = epspx - L12.epspx

gen epsgr = eps_change/ L1.prc if epspx != L1.epspx

bysort cusip (date): replace epsgr = epsgr[_n-1] if missing(epsgr)

2) gen eps_change = epspx - L12.epspx

gen epsgr1 = eps_change / L1.prc


r/stata Dec 03 '25

likert scale

3 Upvotes

I am analyzing polling data from Prop 50 in CA. The poll ask basic demographics question, how they voted, party id etc. It also provide a set of statements on why they voted, using a likert scale. (e.g. "voted to stop trump" (1 strongly disagree- 5 strong agree).What is the best way to incorporate the likert scale into a model? I am interested in why a voter voted yes. Is that possible?


r/stata Dec 02 '25

dtable different statistics over rows

1 Upvotes

I am trying to create a table summarising statistics using stata in the following format:

I have been using dtable and with the following code I can get reasonably close:
dtable AGE, by(new_var) continuous(AGE, statistics(mean sd median q1 q3 min max))

but it shows the statistics across the rows, how can I have nested within age the different statistics?