Dear Listers,
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
, so that it shortens to a two-digit value.
I tried to use
with
. It did not work. The closest I found is this : https://www.statalist.org/forums/for...velsof-command.
Thank you in advance for any tip.
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) }
Comment