Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Date: Sun, 19 Oct 2003 14:31:00 -0400


From   "Cesar Cancho Diez" <[email protected]>
To   <[email protected]>
Subject   st: RE: Date: Sun, 19 Oct 2003 14:31:00 -0400
Date   Sun, 19 Oct 2003 14:07:01 -0500

Hi Erica
Maybe you can use the "subinstr" function as this:
You have a string variable "var1"
          var1
  1.  11-11-01
  2.  11-11-02
  3.  11-11-03
  4.  11-11-04
  5.  11-11-05
You can generate a new variable "var2" where the text "-" is replaced by
"" (this is a no space). The "." after the last comma means that all the
"-" will be replaced:
.gen str12 var2=subinstr(var1,"-","",.)
The result is:
          var1          var2
  1.  11-11-01        111101
  2.  11-11-02        111102
  3.  11-11-03        111103
  4.  11-11-04        111104
  5.  11-11-05        111105
I hope this help... Good luck!

C�sar
Ministry of Agriculture of Peru


-----Mensaje original-----
De: [email protected]
[mailto:[email protected]] En nombre de Erica Seiguer
Enviado el: Domingo, 19 de Octubre de 2003 01:31 p.m.
Para: [email protected]
Asunto: st: Date: Sun, 19 Oct 2003 14:31:00 -0400


I have a variable where the identifier is listed as follows

111-11-11-111

I want to remove the dashes so the variable will just be a string of
numbers.

If anybody has any suggestions I would greatly appreciate it.

Thank you.



*
*   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/


*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index