Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Extracting numbers from code
From
"[email protected]" <[email protected]>
To
[email protected]
Subject
Re: st: Extracting numbers from code
Date
Tue, 13 Nov 2012 14:47:58 -0500
Hi Daniel.
Thank you again for the code. That really helps a lot!
What I have found today, is an error that I am not sure why it occurs
or how to solve it.
While the first part of the code:
g byte dummy1 = (substr(strofreal(a5_bc), 1, 1) == "1") & ///
(cond((strlen(strofreal(a5_bc)) < 5),
cond(!(inlist(substr(strofreal(a5_bc), 2, 1)), "0", "1"), 1, 0), 1))
works very well,
the second part is causing some problems
forv j = 2/11 {
g byte dummy`j' = (strpos(strofreal(a5_bc), "`j'") > 0)
}
The dummies are all correctly created, until the variable a5_bc has
more than 8 numbers. For example:
12347911 is classified under dummies 1,2,3 and 7, but not under
dummies 4, 9 and 11, as it should.
1234568910 is the longest entry I have and that also is not classified
correctly.
Is there possibly a restriction to the length of the variable?
Kind regards
Sanja
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/