<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to flag variables based on string in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305210#M8698</link>
    <description>&lt;P&gt;On a side note, SAS does permit IF/THEN/IF.&amp;nbsp; However, nobody uses it because it doesn't save you anything.&amp;nbsp; (All it really does is make the ELSE statement more difficult to interpret.)&amp;nbsp; For example, here's a test program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;do i=1 to 100000000;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if i &amp;gt; 0 and 5=4 then x=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;do i=1 to 100000000;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if 5=4 and i &amp;gt; 0 then x=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;do i=1 to 100000000;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if i &amp;gt; 0 then if 5=4 then x=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The middle step runs faster because 5=4 is always false.&amp;nbsp; The software is smart enough to figure out that it doesn't need to check the second condition when the first condition is false.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When it comes to your application, why do you need to check all these combinations?&amp;nbsp; If you find "Comprehensive Assessment" isn't that enough so that you don't need to check for variations that would follow?&amp;nbsp; Are there any strings that contain "Comprehensive Assessment" that also contain other characters where it would be incorrect to set CA_ONLY to 1?&amp;nbsp; I realize there are other strings that need to be checked (upper vs. lower case, "ax" vs. "Assessment"), but why do they all need to be checked?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, strings that become lengthy should not generate an error.&amp;nbsp; They should at most generate a warning because the software suspects you have done something wrong.&amp;nbsp; If you know you haven't done anything wrong, you can usually ignore this particular warning.&amp;nbsp; (Very bad advice in general, but applicable in this case.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2016 20:15:10 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-10-17T20:15:10Z</dc:date>
    <item>
      <title>How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305199#M8696</link>
      <description>&lt;P&gt;Hi Everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New to SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to flag all variables with the string "comprehensive assessment".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is part of my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ca_only = 0;
			if prxmatch ("m/Comprehensive Assessment|comprehensive ax|HW - Comprehensive Ax|FA - Comprehensive Ax|FA - Comprehensive Ax TM|HW - Comprehensive Ax TM|FA - Reassessment|HW - Reassessment|Reassessment|Dominance|Comp Ax Telemedicine|Clinic Comprehensive Assessment|Comprehensive Ax - Telemedicine|Comprehensive Ax - TM/oi", description)&amp;gt; 0 then
			if prxmatch("m/Comprehensive Assessment - OT\/PT|Dominance Transfer Training|conc|psych|LIBYA - AX - COMPREHENSIVE ASSESSMENT|LIBYA - AX - COMPREHENSIVE ASSESSMENT OT\/PT|/oi", description) = 0 then ca_only = 1;&lt;/PRE&gt;&lt;P&gt;However, I've reached a point now where it seems my code is too long and I am getting an error message saying I have exceeded 252 characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How else can I find all values that CONTAIN "comprehensive assessment" but also contain other variations like outlined in my above code (e.g., "comprehensive ax", "comprehensive ax-tm", "comp ax") etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advanced!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 19:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305199#M8696</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-10-17T19:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305203#M8697</link>
      <description>&lt;P&gt;Your current code is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If &amp;lt;CONDITION1&amp;gt; THEN&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; if &amp;lt;CONDITION2&amp;gt; then ca_only=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This isn't correct SAS syntax.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If &amp;lt;CONDITION1&amp;gt; &lt;U&gt;&lt;STRONG&gt;&amp;nbsp;&lt;FONT color="#FF0000"&gt;AND&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;&amp;nbsp;&amp;lt;CONDITION2&amp;gt; then ca_only=1;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 19:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305203#M8697</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-17T19:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305210#M8698</link>
      <description>&lt;P&gt;On a side note, SAS does permit IF/THEN/IF.&amp;nbsp; However, nobody uses it because it doesn't save you anything.&amp;nbsp; (All it really does is make the ELSE statement more difficult to interpret.)&amp;nbsp; For example, here's a test program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;do i=1 to 100000000;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if i &amp;gt; 0 and 5=4 then x=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;do i=1 to 100000000;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if 5=4 and i &amp;gt; 0 then x=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;do i=1 to 100000000;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if i &amp;gt; 0 then if 5=4 then x=2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The middle step runs faster because 5=4 is always false.&amp;nbsp; The software is smart enough to figure out that it doesn't need to check the second condition when the first condition is false.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When it comes to your application, why do you need to check all these combinations?&amp;nbsp; If you find "Comprehensive Assessment" isn't that enough so that you don't need to check for variations that would follow?&amp;nbsp; Are there any strings that contain "Comprehensive Assessment" that also contain other characters where it would be incorrect to set CA_ONLY to 1?&amp;nbsp; I realize there are other strings that need to be checked (upper vs. lower case, "ax" vs. "Assessment"), but why do they all need to be checked?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, strings that become lengthy should not generate an error.&amp;nbsp; They should at most generate a warning because the software suspects you have done something wrong.&amp;nbsp; If you know you haven't done anything wrong, you can usually ignore this particular warning.&amp;nbsp; (Very bad advice in general, but applicable in this case.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 20:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305210#M8698</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-17T20:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305284#M8699</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Actually I believe to remember that in some very outdated SAS publication&amp;nbsp;(for SAS V6 I believe) the IF...THEN...IF...THEN construct had been documented as a way to improve performance. This was at a time when SAS always evaluated the full expression in an AND construct even if the first part already resolved to False.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 04:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305284#M8699</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-18T04:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305348#M8707</link>
      <description>&lt;P&gt;Thanks for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to flag all values for the variable DESCRIPTION that contain "comprehensive assessment" BUT ALSO other variation of this like "comprehensive ax" + "comp ax" etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just including "Comprehensive Assessment" in my code doesn't capture the other variations of this. I need to do this b/c this is how we set up our rule for flagging-they all mean the same thing but have different values, which is why we are trying to flag them all the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a better way for me to accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The actual error that I am getting is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;The quoted string currently being processed has become more than 262 characters long.
         You might have unbalanced quotation marks.&lt;/PRE&gt;&lt;P&gt;So I don't think it's actually processing the code that I posted above. which means that i can't ignore it.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 12:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305348#M8707</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-10-18T12:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305359#M8708</link>
      <description>&lt;P&gt;Well, I don't think I can help with PRXMATCH.&amp;nbsp; But you may not need it.&amp;nbsp; Consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;test_string = upcase(description);&lt;/P&gt;
&lt;P&gt;if index(test_string, 'COMPREHENSIVE ASSESSMENT')&lt;/P&gt;
&lt;P&gt;or index(test_string, 'COMPREHENSIVE AX')&lt;/P&gt;
&lt;P&gt;or index(test_string, 'COMP AX')&lt;/P&gt;
&lt;P&gt;then ca_flag=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if I covered every possible case here, but this might be enough.&amp;nbsp; My real point is that you may not need to look for every possible variation of text that might occur.&amp;nbsp; Just locating certian key words may be enough.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305359#M8708</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-18T13:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305370#M8711</link>
      <description>&lt;P&gt;Oh I see what you mean...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so including for just "COMPREHENSIVE" should capture all variations that include that string? So for example, it should also capture "COMPREHENSIVE AX", "COMPREHENSIVE ASSESSMENT" AND "COMPREHENSIVE ASSESS"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I might have tried that before but I don't think it captured all variations (at least not with prxmatch) which is why I had to spell all variations out one by one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for trying to help though!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305370#M8711</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-10-18T13:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305372#M8712</link>
      <description>&lt;P&gt;Patrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That goes back a long way, but I think you're correct.&amp;nbsp; I think it was closer to the end of the version 6 releases (once initial bugs were worked out, efficiency became more important).&amp;nbsp; But I would never swear to it.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305372#M8712</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-18T13:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305376#M8713</link>
      <description>&lt;P&gt;Yes, just COMPREHENSIVE would capture all of those strings.&amp;nbsp; If it didn't last time, it might be the result of different capitalization.&amp;nbsp; But just COMPREHENSIVE might also capture other strings that you don't want as well.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 14:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305376#M8713</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-18T14:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag variables based on string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305535#M8726</link>
      <description>&lt;P&gt;The FIND() function with the 'i' switch for case insensitive search would eventually suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can certainly use a RegEx which matches all the strings - you just must know what the pattern is you're searching for. Can you provide some sample data with the different cases?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 21:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-flag-variables-based-on-string/m-p/305535#M8726</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-18T21:05:59Z</dc:date>
    </item>
  </channel>
</rss>

