Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: left right string


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: left right string
Date   Tue, 18 May 2010 23:08:38 +0200

<>


You can generate the new variables and -destring- (which I assume you also
want) in one fell swoop:


***********
clear*

inp str5 hhh_age
15-19
20-24
25-39 
end

split hhh_age, gen(age) parse(-) destring
rename age1 age_min
rename age2 age_max

list, noo
***********


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: Dienstag, 18. Mai 2010 23:05
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: left right string


<>

Have you had a look at -split-?


HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tyler Frazier
Sent: Dienstag, 18. Mai 2010 23:03
To: statalist@hsphsun2.harvard.edu
Subject: st: left right string

simple question, I hope -- I have a variable which is a range of ages,
for example  the variable name is hhh_age and the quantities are
15-19, 20-24, 25-39 etc...

and I want to generate a new variable (age_min) that returns the left
two characters from hhh_age , and another variable that generates the
right two -- (age_max)

I searched but couldnt find it, seems like a very simple thing, but
cant figure it out.

any help is greatly appreciated

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

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index