Fernando wrote:
> I have a huge data set. The ID variable is like that:
> 05.81-0120
> 25.63-0208
> and so on.
> I want to create a ne ID1 variable, without the "." and the "-",
> and keeping the 0 before the first number:
> 05810120
> 25630208
and there was a suggestion to use -destring-.
Take care with long ID variables, you may get precision problems,
and the best strategy is to keep them as strings. The wanted
transformation to another string variable is shown here:
clear
input str10 id
05.81-0120
25.63-0208
end
gen id2=substr(id,1,2) + substr(id,4,2) + substr(id,7,4)
list , clean
id id2
1. 05.81-0120 05810120
2. 25.63-0208 25630208
Hope this helps
Svend
________________________________________________________
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C, Denmark
Phone, work: +45 8942 6090
Phone, home: +45 8693 7796
Fax: +45 8613 1580
E-mail: [email protected]
_________________________________________________________
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/