[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: New values for a value labelled variable
Call your variable -myid-. First create the
decode myid, gen(MYID)
Then split into numeric and name parts:
split MYID, p(-) destring
You should have MYID1 with the numbers
and MYID2 with the names. If not, my
code is wrong or you are not explaining
Getting first occurrence in the dataset
was discussed on the list only a few weeks ago
and has been written up as an FAQ.
(So, evidently, you did not follow advice
and look at the FAQs on this problem.)
Use that to get a -myid1-.
egen work = concat(myid1 MYID2), p(-)
and get back in the realm of value-labelled
encode work, gen(newid)
> I have a variable with (many) value labels, say
> I would like to create a new variable with consecutive values
> to the old labels, e.g.
> It is important that the sequence of names is preserved.
* For searches and help try: