<>
Jose could also use:
*******
clear*
inp byte var1 str1 var2
1 a
1 a
1 a
1 b
2 m
2 m
2 n
2 n
2 p
3 c
3 c
3 c
3 c
end
compress
contract var1 var2
bys var1: gen byte num=_n
expand _freq
sort var1 var2
drop _freq
li, noo sepby(var1)
*******
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of José Maria
Sent: Samstag, 14. November 2009 16:12
To: [email protected]
Subject: st: generating a new numerical variable3 using a string variable2
which is nested in a numerical variable1
Dear Statalisters:
sorry for so long a name in the subject.
I need to generate a variable3 which is the numerical identification
of a string variable2, that is nested in alphabetical order in a numerical
variable1. The final result would be something like
var1 (already exist) var2 (already exist) var3 (to be generated)
1 a 1
1 a 1
1 a 1
1 b 2
2 m 1
2 m 1
2 n 2
2 n 2
2 p 3
3 c 1
3 c 1
3 c 1
3 c 1
Thanks for any help.
José Maria
Jose Maria Pacheco de Souza, Professor Titular (aposentado)
Departamento de Epidemiologia/Faculdade de Saude Publica, USP
Av. Dr. Arnaldo, 715
01246-904 - S. Paulo/SP - Brasil
fones (11)3061-7747; (11)3768-8612;(11)3714-2403
www.fsp.usp.br/~jmpsouza
__________ Informação do ESET NOD32 Antivirus, versão da vacina 4607
(20091114) __________
A mensagem foi verificada pelo ESET NOD32 Antivirus.
http://www.eset.com
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/