- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have to flag for a list of medications in a character variable which contains user entered free form text. The variable is the question "what prescription medications are you taking".
I have a list of opioids that I need to flag for but when I do my prxmatch I get the error
" The quoted string currently being processed has become more than 262 characters long"
My list of opioids are very long, probably about 40 meds and I don't know how to get around this.
This is the code I was using:
data opioid_analysis; set medeval.opioid; /*Opiod Flagging*/ if prxmatch("m/Butrans|Codeine|Dalmacol|Demerol\/pethidine|Dilaudid|Dimetapp-C|Dimethane|Duragesic|Hycodan|Hydromorph Contin|Kadian|Lenoltec|Methadone|Methoxacet/oi", MED_REC_PMED1)> 0 then opioid = 1; else opioid=0; run;
If I keep adding medications I get the error.
How can I get around this?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The "limit" is much longer. What you received was not an error. It was a warning. Some times people forget to close a quoted string properly such as:
If x ='some text; <= Not missing '
And more code goes here, several lines for over 250 some characters;
Variable = 'Another string';
So the first assignment doesn't end until the ' before "Another".
The warning reminds you to check for something like that. The specific semi-example I provided would generate other errors but you can't be sure it will all the time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think I figured it out!
I added the options noquotelenmax; before my datastep and it seems to work.
options noquotelenmax; data opioid_analysis; set medeval.opioid; /*Opiod Flagging*/ if prxmatch("m/Butrans|Codeine|Dalmacol|Demerol\/pethidine|Dilaudid|Dimetapp-C|Dimethane|Duragesic|Hycodan|Hydromorph Contin|Kadian|Lenoltec|Methadone|Methoxacet|Methoxisal C1\/8|Methoxisal C1|MS contin|Novahistex DH|Novahistine DH|Nucynta|Oxycontin|OXY-IR|OxyNEO|Percocet/oi", MED_REC_PMED1)> 0 then opioid = 1; else opioid=0; run;
I can't see any problems with this if anyone else can comment?
Why does sas bother putting a limit on strings?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The "limit" is much longer. What you received was not an error. It was a warning. Some times people forget to close a quoted string properly such as:
If x ='some text; <= Not missing '
And more code goes here, several lines for over 250 some characters;
Variable = 'Another string';
So the first assignment doesn't end until the ' before "Another".
The warning reminds you to check for something like that. The specific semi-example I provided would generate other errors but you can't be sure it will all the time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Oh that is so weird.
I didn't change my code at all but just added the
options noquotelenmax;
And my code works after having added that!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your code works regardless of the log warning and as @ballardw states the log message is a warning only and the option allows you to switch it off.