Statalist


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

Re: Fwd: st: Data management question


From   "Susan Olivia" <olivia@primal.ucdavis.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: Fwd: st: Data management question
Date   Wed, 15 Jul 2009 21:55:37 -0700

Thanks Tirthankar,

Using Nick Cox's command is way more efficient. My earlier
attempts were very inefficient. 

Cheers,

Susan



> ---------- Forwarded message ----------
> From: Tirthankar Chakravarty
> <tirthankar.chakravarty@gmail.com> Date: Thu, Jul 16, 2009
> at 11:45 AM Subject: Re: st: Data management question
> To: statalist@hsphsun2.harvard.edu
> 
> 
> <>
> There are probably many ways of doing this, but here is
> way using Nick Cox's -egenmore- (SSC, Nick Winter is
> attributed as the author of the -noccur()- function used
> here) package: ********************
> clear*
> set obs 100
> g crosses = " "
> local cross "x"
> forv i=1/ 100 {
>        qui: replace crosses="`cross'" in `i'
>        local cross "`cross'x"
> }
> // ssc install egemore, replace
> egen noccur = noccur(crosses), string("x")
> su noccur
> ********************
> 
> T
> 
> On Thu, Jul 16, 2009 at 2:26 AM, Susan
> Olivia<olivia@primal.ucdavis.edu> 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/
> >
> 
> 
> 
> --
> To every Ï?-consistent recursive class κ of
formulae
> there correspond recursive class signs r, such that
> neither v Gen r nor Neg(v Gen r) belongs to Flg(κ)
(where
> v is the free variable of r).
> 
> *
> *   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