I have two variables, x
and y
.
x
is an index variable that takes the average standardized response of some survey questions.
y
contains the average percentile of the index by region.
I need to create a new variable, z
that calculates the quantiles of the variable x
based on the percentiles of y.
I have the R code to do this:
data <- within(data, z <- quantile(x, c(y), na.rm=T))
Is there an easy way to do this in STATA?
.