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]
SV: st: range of a stringvariable
From
"Tomas Lind" <[email protected]>
To
<[email protected]>
Subject
SV: st: range of a stringvariable
Date
Wed, 28 Apr 2010 17:21:25 +0200
Martin and Rich,
It´s so easy when you point it out. Why didn´t I see that? Maybe I thought
it was something more fancy!
Many thanks
/Tomas
-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Martin Weiss
Skickat: den 28 april 2010 17:11
Till: [email protected]
Ämne: AW: st: range of a stringvariable
<>
Try
*************
real(substr(code,2,3))<=499
*************
instead.
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Mittwoch, 28. April 2010 17:09
An: [email protected]
Betreff: SV: st: range of a stringvariable
Tanks for your kind answer. However I get an error message "type mismatch"
when trying to execute:
gen byte newvar=substr(code,1,1)=="E" & real(substr(code,2,3))>=300 & ///
real(substr(code,2,3)<=499 ) & length(code)==4 ) )
This part of the statement works
gen byte newvar=substr(code,1,1)=="E" & real(substr(code,2,3))>=300
but when adding this part (second line)
gen byte newvar=substr(code,1,1)=="E" & real(substr(code,2,3))>=300 & ///
real(substr(code,2,3)<=499 )
I get an error message "type mismatch
/Tomas
-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Richard Goldstein
Skickat: den 28 april 2010 16:19
Till: [email protected]
Ämne: Re: st: range of a stringvariable
for the first question:
gen byte newvar=substr(code,1,1)=="E" & real(substr(code,2,3))>=300 &
real(substr(code,2,3)<=499 & length(code)==4
for the second question (end with "A") I would replace "length(code)==4"
with substr(code,5,1)=="A"
here I am using "code" for the name of the variable with the ICD-10 code
Rich
On 4/28/10 10:02 AM, Tomas Lind wrote:
> Dear listers
>
> Choose individuals based on a string variable with a range of values
>
> I am working with ICD-10 codes (codes for different types of diseases).
The
> codes start with a letter A - Z followed by 2 or 3 digits. In some cases
> they might end with the letter A. Say that I have a dataset with 5 subjets
> (id=1 to 5) with these ICD-10 codes (fake data, in reality I have millions
> of subjects):
>
> I460 E343 I46 C764 E438
>
> How can I choose individuals with ICD-10 codes in the range E300 to E499
> (not including codes that end up with A). What about if I want to include
> codes that ends with an A. (There is a convenient command for ICD-9 codes,
> but not for ICD-10 codes.)
>
> Any suggestions are welcome.
>
>
> /Tomas
*
* 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/
*
* 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/