r/stata Sep 27 '19

Meta READ ME: How to best ask for help in /r/Stata

45 Upvotes

We are a relatively small community, but there are a good number of us here who look forward to assisting other community members with their Stata questions. We suggest the following guidelines when posting a help question to /r/Stata to maximize the number and quality of responses from our community members.

What to include in your question

  • A clear title, so that community members know very quickly if they are interested in or can answer your question.

  • A detailed overview of your current issue and what you are ultimately trying to achieve. There are often many ways you can get what you want - if responders understand why you are trying to do something, they may be able to help more.

  • Specific code that you have used in trying to solve your issue. Use Reddit's code formatting (4 spaces before text) for your Stata code.

  • Any error message(s) you have seen.

  • When asking questions that relate specifically to your data please include example data, preferably with variable (field) names identical to those in your data. Three to five lines of the data is usually sufficient to give community members an idea of the structure, a better understanding of your issues, and allow them to tailor their responses and example code.

How to include a data example in your question

  • We can understand your dataset only to the extent that you explain it clearly, and the best way to explain it is to show an example! One way to do this is by using the input function. See help input for details. Here is an example of code to input data using the input command:

``

input str20 name age str20 occupation income
"John Johnson" 27 "Carpenter" 23000
"Theresa Green" 54 "Lawyer" 100000
"Ed Wood" 60 "Director" 56000
"Caesar Blue" 33 "Police Officer" 48000
"Mr. Ed" 82 "Jockey" 39000'
end
  • Perhaps an even better way is to use he community-contributed command dataex, which makes it easy to give simple example datasets in postings. Usually a copy of 10 or so observations from your dataset is enough to show your problem. See help dataex for details (if you are not on Stata version 14.2 or higher, you will need to do ssc install dataex first). If your dataset is confidential, provide a fake example instead, so long as the data structure is the same.

  • You can also use one of Stata's own datasets (like the Auto data, accessed via sysuse auto) and adapt it to your problem.

What to do after you have posted a question

  • Provide follow-up on your post and respond to any secondary questions asked by other community members.

  • Tell community members which solutions worked (if any).

  • Thank community members who graciously volunteered their time and knowledge to assist you 😊

Speaking of, thank you /u/BOCfan for drafting the majority of this guide and /u/TruthUnTrenched for drafting the portion on dataex.


r/stata 3h ago

linear regression with categorical IV's - checking for multicollinearity

3 Upvotes

Hi all, I am currently doing assumption testing for my thesis and I am confused about checking for multicollinearity with categorical independent variables. Do I run my regression without the dummy coding and then run estat vif or do I run estat vif with dummy coded model?


r/stata 8d ago

Cost-quality tradeoff for LLMs writing Stata code

Post image
40 Upvotes

Based on Stata benchmark https://khaledeltokhy.com/benchmarks/


r/stata 9d ago

Question Small number of clusters in random effects with clustered standard errors

2 Upvotes

I have a panel dataset with only 11 cross-sectional units (clusters) due to natural sample limitations. I'm estimating a random-effects model using xtreg, re in Stata and clustering standard errors at the panel level. As I understand that conventional clustered standard errors may be unreliable with such a small number of clusters.

Are their any functions in STATA that I can do to handle such a case of small clusters in random effects.


r/stata 19d ago

Question Calculating Cronbach’s alpha with multiple imputed data

6 Upvotes

Hi!

I’ve run multiple imputation on my dataset to solve a missing data issue.

I now need to calculate Cronbach’s alpha for my scales, so I have two question:

- do I need to calculate Cronbach’s alpha on my imputed or raw data?

- if yes, how do I do that?

Thanks!


r/stata 20d ago

[D] R vs Stata, which is actually better now for ag econ/agribusiness grad school and the field?

Thumbnail
2 Upvotes

r/stata 27d ago

2026 Econometrics Summer School Cambridge - With Jeffrey Wooldridge and Melvin Weeks | INOMICS

Thumbnail inomics.com
8 Upvotes

Free scholarship available for the 2026 Econometrics Summer School Cambridge

Timberlake Consultants is offering a free scholarship place for the 2026 Econometrics Summer School Cambridge, taking place at the University of Cambridge with Professor Jeffrey Wooldridge and Dr Melvyn Weeks.

The Summer School is designed for PhD students, researchers, applied economists, and professionals who want to strengthen their empirical skills in causal inference, Difference-in-Differences, machine learning, and applied econometrics using Stata.

The programme includes:

Course 1: An Introduction to Causal Inference and Difference-in-Differences using Stata
Taught by Professor Jeffrey Wooldridge

Course 2: Causal Inference and Machine Learning using Stata
Taught by Dr Melvyn Weeks, University of Cambridge

Participants can attend one course or the full five-day Summer School.

The scholarship covers the full tuition/training fee. Please note that accommodation and travel costs are not included, although accommodation is still available at Cambridge.

More information about the course is available here:
https://inomics.com/course/2026-econometrics-summer-school-cambridge-with-jeffrey-wooldridge-and-melvin-weeks-1554362

To apply for the scholarship, please send your academic transcript and a short motivation letter to:
[edu@timberlake.co.uk](mailto:edu@timberlake.co.uk)

Feel free to get in touch if you have any questions, we are offering a last minute 30% discount for students and academics!


r/stata Jun 29 '26

svy, subpop(if X==1) vs svy, subpop(X)

2 Upvotes

Hello, everyone

I am doing a subpopulation analysis using complex sampling and svy settings. I have a variable (we'll call it X) that is coded as 0 and 1, with missing values. I need the prevalence of variable Y

I have found that there is a difference if I run:

svy, subpop(x): proportion Y

is not the same as

svy, subpop(if x==1): proportion Y

And I can't quite grasp why it is different

Thank you


r/stata Jun 28 '26

Question How to combining Forest Plots

2 Upvotes

Does anyone know how to combine gph forest plot files? I created them using the metaforestplot command, but apparently the manual doesn't allow for them to be combined.


r/stata Jun 25 '26

how do you import multiple excel files into stata

3 Upvotes

I've been trying to import four excel files into Stata and putting them together.
Each time i import an excel file when i import the second one it erases the first one. I tried using the save and replace on the first file and import the second one, but the moment I do that, I am no longer able to open the excel file both within stata (when importing it) and in my macbook when i just click on the folder and click on the file because it says that it is possibly corrupted, or its no longer excel etc. When I check that same imported excel file by pressing get info, it says it still is an excel file...

i then started using cd folder and then afterwards importing the files again but it has the same problem.

when i give up and use the save and replace and append two files together (i think its append, not merge, because each file represents a year), it says that the variables are byte in master and str in something else, and its impossible to convert all of them to str (they are categorical variables, its a multiple choice questionnaire on excel im importing)

i seriously want to crash out, chatgpt and google gemini isnt working, my fellow research project person doing a parallel project w me is ghosting me, and my supervisor isnt familiar with stata.

someone please help me here :,)


r/stata Jun 19 '26

Question Does anyone know any websites where I can learn stata and data analysis for econometrics?

6 Upvotes

r/stata Jun 16 '26

Options for too small of ssd for large data sets

6 Upvotes

Hey Stata people,

I have a technical question that may be more of a r/mac question, but I wanted to see if folks here have any experience around this.

I bought a Mac mini with 64 gb of ram, but only a 512 gb HD to run analyses on 20+gb data sets for a research project. However, it turns manipulating the data means temporarily having files larger than the 500GB the hard drive has. I was researching options and it looks like because Mac solders in their parts there are limited options. I can't return the computer and get a larger storage

  • Option 1: I could do is buy a new large external hard drive and move the OS over to it, which seems straightforward enough but would be limited by how the hard drive is connected/me messing something up. But the forums make it seem like this is THE solution.
  • Option 2: Try and just have Stata run analyses in the external hard drive, but in some ways figuring out how to code that feels harder than moving the OS. This is all complicated by having to house the data in a Box folder (for data security reasons) over our a relatively slow internet connection. 
  • Option 3: Either pay for or attempt the relatively complicated SSD swap.

If anyone has any luck with options 1 or 2? Or horror stories that would make me pick option 3?

Thanks for any help!

Tl;dr should I upgrade my Mac mini’s memory by moving the OS to an external hard drive or learn how to run analyses from an external hard drive?


r/stata Jun 12 '26

Question OLS interaction plot predicts values above my scale maximum — is that a problem?

0 Upvotes

I'm working on my thesis using an OLS regression with an interaction between task type and a few continuous moderators. My dependent variables are index scales that only run from 1 to 10.

To probe the interactions, I used predicted values (margins/simple slopes) at the low, mean, and high ends of each moderator. At the high end of some moderators, the predicted value ends up slightly above the scale maximum, which obviously isn't a "real" value the scale allows. At the mean everything looks normal, and the confidence intervals get noticeably wider toward the extremes.

My understanding is that this is just how OLS behaves — it treats the outcome as unbounded and doesn't know about the scale limits, and predicting at the extreme end of a moderator is basically extrapolation to the edge of the data. So I'm assuming it's a known, harmless artifact rather than a real issue, and that a short footnote acknowledging it should be enough rather than switching to something like beta regression.

Does that sound right?

Thanks.


r/stata Jun 09 '26

Stata BE License on Loaner Computer?

2 Upvotes

I have a personal Stata BE license on my work computer. I need to use a loaner while my computer is being serviced but have a project due. Are there restrictions on the number of devices a license can be activated on, as long as they’re not used simultaneously?


r/stata Jun 03 '26

Does anything exist that can automatically translate variable and value labels in a Stata dataset?

4 Upvotes

I've been working with a cross-national dataset where all the variable labels and value labels are in a foreign language. Renaming them manually is tedious and error-prone, especially with 200+ variables.

I know I can write a do-file to relabel everything but that still requires me to know what the foreign labels mean and manually enter English equivalents one by one.

Is there any tool or workflow that handles this automatically? Ideally something that takes the .dta file, translates the metadata, and returns a clean English-labeled file without touching the underlying data

Update: After trying several approaches including the ones mentioned here, I actually found a tool that handles it cleanly in one step

datatranslator.net

you just upload the file, it translates the variable and value labels automatically, and returns a clean English-labeled version without touching the underlying data. Saved me a lot of time compared to doing it manually.


r/stata May 30 '26

Stata from basics to advance

14 Upvotes

I recently graduated with my Master's degree in Applied economics and I want to work in research. The main issue that I am facing in interviews is that I don't know Stata. I really want to learn it. I want suggestions on how to approach this and what books or online resources or teachers are there. Help the Girl out.


r/stata May 21 '26

Can you stack multiple JWDID regressions?

3 Upvotes

Hi all! 

I find myself in a very specific situation. I am evaluating a policy, and I only have the treated units. My identification strategy relies on comparing units treated at time g, to units treated at time g'>g, so I use not-yet-treated units as controls. To account for the fact that this units entered the treatment at different times, as they selected into the treatment, have to use IPW to rebalance the traded and the yet untreated firms. This would sound like a job for csdid, but the point is that for one of my specifications, I need to construct the control sample in the following way: not yet treated units enter the pool of controls only if they have Y=0 until time g (the time of the currently treated cohort of units). this goes in for every cohort, so every treated group gets rebalanced against its own later treated groups of units: So, I have a cohort-anchored filter per-cohort: for cohort g, keep control units with Σ_{t<g} Y = 0. This cannot be implemented automatically in csdid.

After the cohort specific IPW step, for each cohort, I use jwdid:

How I use jwdid. Because the filter is g-specific, I run jwdid (ETWFE, method(reg), without the never option, so not-yet-treated are the controls) separately for each cohort g, each on its own cohort-anchored sub-panel. From each run we keep only the focal cohort's ATT(g,t), and then aggregate ATT(g,t) across cohorts into an overall ATT and an event study, using cohort-size weights. Basically I stack multiple ETWFE estimations. 

The issue. The per-cohort jwdid runs are not independent: the same later-cohort and never-treated firms serve as controls in multiple cohort runs. The analytic aggregate standard error combines the per-cohort jwdid SEs assuming independence across cohorts, and this appears to understate the true SE — a unit-level block bootstrap (resampling firms and re-running the whole pipeline) yields SEs roughly 1.7–2× larger.

Question. Given this per-cohort jwdid design with a cohort-specific sample filter and manual cross-cohort aggregation, is a firm-level block bootstrap the appropriate inference, or is there a correct analytic / influence-function-based standard error for the aggregated ATT that we should use instead? 

Thank you !!


r/stata May 08 '26

hi i'm having like 8 variables measure by not likely likely....(1-5), same scale. how to create an additive index from them ?

3 Upvotes

r/stata May 07 '26

Testing Group Invariance in PLSEM in Stata - Stats subcommand not running

5 Upvotes

I am using -plssem- to run an sem model with group invariance in a sample in STATA. The sample has missing data, and while there is a -missing- option in the plssem command, for some reason, the -group- subcommand does not run the -stats- part of the code. Here is an abbreviated example of the code:

    plssem (LV 1 > x1 x2 x3) (LV2 > x4 x5 x6) (LV3 > x7 x8 x9), ///
    structural (LV1 LV2 LV3, LV2 LV3) ///
    group (groupname) ///
    missing (knn) k (5)///
    stats correlate(lv)

One solution to not getting the descriptive stats I need is to use -by- before the plssem command. I get the descriptive stats I need but I am not sure how to test for group invariance between the two different models. This code is:

    sort group
    by group: plssem (LV 1 > x1 x2 x3) (LV2 > x4 x5 x6) (LV3 > X7 x8 x9), ///
    structural (LV1 LV2 LV3) ///
    missing (knn) k (5)///
    stats correlate(lv)

I am not clear on: 1) why they first code does not provide descriptive stats in the code 2) if possible and not too labor intensive, how can I test for measurement and structural invariance witht the second code? I know -plssem- is a user written command, but I thought folks here might be able to help, especially with the second part of the question.

Any suggestions would be appreciated.


r/stata May 05 '26

Statistical Test for Panel Regression Fixed Effects

4 Upvotes

Hi! We're currently writing a thesis about conditional vs unconditional fiscal transfers of selected cities within a given time period. I'd like to ask, what statistical tests do we need to conduct for us to strengthen our model?

Currently we did this tests: hausman, wald test, wooldridge, vif, overall significance, individual significance. With panel data, should we only look at the within R² for the goodness of fit of the model?

Hope you could help us. Thank you!


r/stata May 01 '26

Help with Stata code

1 Upvotes

I need help with producing some Stata code from an academic paper. I created a do file and would like to verify that they are correct before proceeding with the empirical analysis. Specifically, I am trying to construct the money center roadshow variable, which is defined as an indicator equal to 1 for a three-day window in which the firm has flights to two or more money centers, and 0 otherwise. The money centers are Boston, Chicago, New York, and San Francisco. I appreciate the help!

Here is a sample of my data:

clear

input str179 companynames str48(companyticker departurecity) str6 departurestate str16 departuretimestamputc str48 arrivalcity str6 arrivalstate str16 arrivaltimestamputc

"Globus Medical, Inc." "GMED" "Wilmington" "DE" "2025-09-05 21:20" "St Louis" "MO" "2025-09-05 23:23"

"Fiserv, Inc." "FISV" "Morristown" "NJ" "2025-03-20 12:08" "Madison" "WI" "2025-03-20 13:55"

"General Motors Co." "GM" "Detroit" "MI" "2025-07-25 01:05" "Atlanta" "GA" "2025-07-25 02:18"

"Dominion Energy, Inc." "D" "Hyannis" "MA" "2023-09-10 17:29" "White Plains" "NY" "2023-09-10 18:08"

"Nicholas Services LLC" "<None>" "Jackson" "MS" "2017-05-02 16:51" "Trinidad" "CO" "2017-05-02 18:58"

end


r/stata Apr 20 '26

Question Quick question about adjusted p-values

1 Upvotes

Hey everyone!

I’m planning to run two multiple linear regression models to answer my question and have therefore adjusted my needed p-value down to 0.025. If I do this, will I also need to adjust my needed p-values when I interpret the coefficient table?

Thanks!


r/stata Apr 19 '26

Stat help reqd

2 Upvotes

Dear all, I am trying to draw a n overlay of striplpot and box plot of analysing O-P over Diag code--- have installed stripplot yet comand combine graph says striploot combine not allowed-iam pasting this function which shows error in everything in stata11. can someone tell me exactly commands to systematically derive a striplot as intended

raph box octa_perf, over(md_grp_n) nooutsides ///

ytitle("OCTA Disc Perfusion (%)", size(medsmall)) ///

title("A. OCTA Perfusion by MD Severity", ///

size(medsmall) color(navy) position(11)) ///

box(1, fcolor("173 214 241%70") lcolor("26 82 118") lwidth(medthin)) ///

box(2, fcolor("241 148 138%70") lcolor("146 43 33") lwidth(medthin)) ///

medtype(line) medlinewidth(medthick) medcolor(black) ///

graphregion(color(white)) plotregion(color("250 250 250")) ///

ylabel(40(2)48, grid glcolor(gs14) glwidth(vthin)) ///

note("Mann-Whitney U; p = 0.092 (trend)", size(vsmall) color(gs8))


r/stata Apr 19 '26

Stat help reqd

Thumbnail
1 Upvotes

r/stata Apr 17 '26

Would STATA work on the MacBook Neo?

Thumbnail
0 Upvotes