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

st: RE: Splitting a string variable


From   "Munro, Cameron" <[email protected]>
To   <[email protected]>
Subject   st: RE: Splitting a string variable
Date   Mon, 17 Oct 2005 06:54:46 -0700

Ilaria

-substr- should do what you need. So, assuming you always have 4 digits followed by two characters in variable str, try substr(str,1,4) for the digits and substr(str,-1,2) for the characters. See help strfun.

Cameron.

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Mosca, Ilaria
Sent: 17 October 2005 14:43
To: [email protected]
Subject: st: Splitting a string variable


I am dealing with a string variable that has 4 figures and 2 letters,
something like this: 1234AB
As you can see there is no space, or comma, etc. divinding the figures
from the letters. 
What I wanna do is to create a new variable where I only keep the
figures and drop the letters. How can I do that? Does the command SPLIT
help me in this? 

Thank you very much.

Ilaria 

Met inachtneming van eventuele beperkende bepalingen in deze e-mail, mag u deze informatie gebruiken voor het doel waarvoor u die ontvangt. Aan deze gegevens kunnen geen rechten worden ontleend. CTG/ZAio aanvaardt geen aansprakelijkheid voor de juistheid en volledigheid van deze gegevens. Enige schade, ontstaan door de ontvangst of het gebruik van dit e-mailbericht of de informatie daarin, komt voor uw eigen verantwoordelijkheid.


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


--------------------

This email message is for the sole use of the intended recipient(s) and
may contain privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.



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