Hi Statalisters,
I've merged two datasets which are cross-sectional(year of 2004) and time series(year from 2012-2015) with student id.
Because the variables from those two are different, I should fill the missing values in the rest 4 years with the number in year 2004.
Searching Statalist, I found the following code to fill the BYAID for 2012-2015 with 2004.
bysort BYSID (BYAID) : replace BYAID = BYAID[_n-1] if missing(BYAID)
However, there are a bunch of other variables starting with BYA#, BYT#, FY#... (# means series of numbers).
I've tried with the following code,
bysort BYSID (BYA*) : replace BYA* = BYA*[_n-1] if missing(BYA*)
But there was error message : BYA ambiguous abbreviation
How could I fill all the missing variable with these prefix, without error??
Related Posts with Filling a number of missing variables sharing prefix with "replace"
The Monty Hall problem through permutations: can somebody translate the Stata code below to R code?Good morning, I have written a paper on how one can use the Monty Hall problem (with the 3 doors an…
Sorting data in chronological orderHello, This post is similar to what I previously posted here: https://www.statalist.org/forums/for.…
Clarification neededDear StataList, I am reading an interesting paper by Brons et al. (2017), where on page 812 they de…
CMP model with interaction between endogenous and exogenous variablesDear all, I am having an endogenous variable X1 and an exogenous variable X2 and instruments Z1 and…
STATA command to execute code and return error messageHello, I have written a script to automatically run several do files in a folder and print either s…
Subscribe to:
Post Comments (Atom)
0 Response to Filling a number of missing variables sharing prefix with "replace"
Post a Comment