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: macros of multiple complex strings
From
David Lockhart <[email protected]>
To
[email protected]
Subject
st: macros of multiple complex strings
Date
Tue, 2 Jul 2013 15:28:28 -0700
I have a dataset with information on surgeries recorded by CPT codes. Each
patient has up to 21 CPT codes in variables called cpt othercpt1 ...
othercpt10 concpt1 ... concpt10.
I also have several lists of CPT codes which include procedures of
interest. For example, 6 codes which involve lymph node dissection (LND). I
am trying to create a variable which has the value 1 if the surgery
involved LND and 0 if it did not.
But some codes are ambiguous, for example the code 58960 includes removal
of tumor with or without LND. Each CPT code field has an accompanying text
field which holds a brief text description describing the procedure, and
sometimes this can disambiguate these codes. I have made a list of the
values this text field takes on for the ambiguous codes and have selected
those which I wish to count as indicating that LND was performed. But I'm
having trouble setting up the code to do this.
Here's what I'm trying that isn't working. The first loop works but the
second does not.
gen lym = 0
foreach cptfield of varlist cpt othercpt* concpt*{
foreach cptcode of numlist 38562 38564 38570 38571 38572 38589 38770
38780 58200 58210 ///
58548 58943 58951 58954 59548 {
qui replace lym = 1 if `cptfield' == `cptcode'
}
}
foreach textfield of varlist prncptx otherproc* concurr* {
foreach proc in "LAPT STG/RESTG OVARIAN TUBAL/PRIM MAL 2ND LOOK" ///
"RESECT RECUR GYN MAL W/LYM" "BSO W/OMNTC TAH DEBULKING W/LMPHADEC" ///
"LAPS W/RAD HYST W/BILAT LMPHADEC RMVL T" "RAD ABDL HYST W/BI PEL
LMPHADEC" ///
"RESECTION RECRT MAL W/OMENTECTOMY PEL LMPHADEC" ///
"LAPAROTOMY, FOR STAGING OR RESTAGING OF OVARIAN,"{
replace lym = 1 if `textfield' == `proc'
}
}
When I run this, I get an error that "LAPT not found". So, I can tell it
is trying to split up that string into "words", but I don't understand why
or how to get it to treat the strings as separate units.
*
* 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/