Hi,
I am using Stata 16.1, and have the following (general) issue. I want to drop duplicate observations of one variable (educ) from my dataset but conditioned on another variable (year).
I've found an online dataset, such that it may be easier to talk about. First up I apologize that I am new Stata.
My problem: I want to drop all duplicates of educ for each corresponding year (72 & 74). This means I do not want educ's value to enter for year 72 if it's value has already been observed.
Here is what I've tried do to:
use http://fmwww.bc.edu/ec-p/data/wooldridge/fertil1
keep if year == 72 | year == 74
drop if educ == educ[_n-1] & (year == 72 | year == 74)
The problem:
I am not dropping all duplicates of educ
Any suggestions would be appreciated
Related Posts with Dropping duplicate observations conditioned on another variable
How to remove vertical line from do-file editorHello there, Is there a way to disable a vertical line from do-file editor? It is not comfortable t…
Extrem RRR value in logit regressionHi I am running mlogit to for knowing which places immigrants choose to live initially. my dependent…
Including a quadratic term in a linear regression - what to do here?Hi, I am running a linear regression in Stata 17, using the regress command. Based on theory I susp…
Data visualization: Dotplot w/ labelled ylinesDear Stata users, I am trying to make a dotplot similar to the one below, except I would have liked…
Date variable conversion from string formatHi everyone, I have date variables in the following format - yyyymmdd_hhmmss I've looked at the exi…
Subscribe to:
Post Comments (Atom)
0 Response to Dropping duplicate observations conditioned on another variable
Post a Comment