I am using Stata 15.1.
I am working with a dataset with more than a million observations.
I would like to change the values of a variable in order to merge another data with one of the data having an "ID" which is one digit higher than the master data. So I would like to drop the last digit in the using data in order to merge the two datasets.
What I want: In the following synthetic data, I would like to get rid of the last digit number from the values off variable
length
I tried to use
levelsof
usubstr
Code:
sysuse auto, clear levelsof length, local(levels) foreach l of local levels{ gen length2=usubstr("`levels'", 1, 2) }
0 Response to chnaging values of a variable
Post a Comment