Statalist


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

Re: st: Data management question


From   Jeph Herrin <junk@spandrel.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Data management question
Date   Thu, 16 Jul 2009 10:39:27 -0400


how about

  gen days=len(subinstr(myvar," ","",.))

?


Susan Olivia wrote:
Dear Stata lister,

I have a variable (say number of days) and is a string
variable. This variable is represented by XXXX (basically
the number of X denotes the number of days).
I would like to create a numeric value for this variable
(i.e. 4 crosses = 4) . Is there a way I can easily do this
in Stata? I tried the 'encode' and 'destring' commands, but
these commands didn't do what I after.
Thanks in advance for the tips,

Susan


*
*   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   |   What's new   |   Site index