I have a data set and I am trying to flag all variables that have the word "treatment" or "tx" with a 1 else 0. However, there are some observations which have the following description: "Supplies-treatment" or "supplies-tx". For these, I DO NOT want them to be flagged with a 1. Here is my code: data flagtx; set flagtxdc; if prxmatch("m/tx|treatment|treat/oi",description) > 0 then tx=1; else tx=0; run; this works perfectly! When I run a proc freq I see that there are 33314 obs flagged with a 1. But then I want to unflag all the descriptions that have the word "supplies" in them. In order to accomplish this I thought I could use a prxmatch as above but on the new dataset I just created with all the words "treatment" flagged with 1, and when it came across any descriptions with "supplies" it would flag it as a 0. I used this code next after running the above code to accomplish the aforementioned: data flagtxsupplies; set flagtx; if prxmatch("m/supplies/oi",description) > 0 then tx=0; else tx=1; run; However, when I run a proc freq, I see that it has incorrectly flagged my variables somehow. Instead of having LESS than 33314 obs flagged with a 1 (which should be the case because I am eliminating "supplies-treatment") I actually have MORE obs that have been flagged with a 1. 64174 to be exact! I did a proc print on 100 obs but everything looks good..what is going on?? What is my code doing exactly? Thank you
... View more