Bookmark and Share

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]

st: AW: SV: AW: range of a stringvariable


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: SV: AW: range of a stringvariable
Date   Wed, 28 Apr 2010 16:56:56 +0200

<> 


" Out of curiosity what happens with the A in 543A in the statement below?

split remainder, parse(A)"


The -parse()- character is zapped, unfortunately. That is usually what
-split- users want. Of course you can always separate the string with
-substr()-, as shown earlier.




HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Mittwoch, 28. April 2010 16:45
An: [email protected]
Betreff: st: SV: AW: range of a stringvariable

Thanks Martin for your kind help. 

Out of curiosity what happens with the A in 543A in the statement below?

split remainder, parse(A)

I thought that the statement above meant that I should get 2 variables
ICD-10, with and without the A. However I just get one new variable,
remainder1 (which is the ICD-10 numbers without the trailing A, enough for
the code to work).

/Tomas




-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Martin Weiss
Skickat: den 28 april 2010 16:13
Till: [email protected]
Ämne: st: AW: range of a stringvariable


<> 

You have to get a little creative for this one:

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

input str5 code
I460  
E343  
I46  
C764  
E543A
E438
end

gen letter=substr(code,1,1)
gen remainder=substr(code,2,5)
gen byte hasA=substr(remainder,4,4)=="A" if length(remainder)==4
split remainder, parse(A)
l
list if letter=="E" & inrange(real(remainder1),300,499)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Mittwoch, 28. April 2010 16:03
An: [email protected]
Betreff: st: range of a stringvariable

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index