<?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: Specifying an alphabetic range in an &amp;quot;if&amp;quot; statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130415#M26608</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your answers; as usual I have learnt a lot more than the original question was posing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike: I tried looking up an opposite for the "rank" function (returns the character for a given rank) to help this kind of code work on different platforms, because I had to change the range to (193:199) for z/OS, but I could not find any - not a problem though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Astounding: Thank you for your solution and flagging the subtleties of the ranges for both numeric and character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2012 10:35:57 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2012-06-01T10:35:57Z</dc:date>
    <item>
      <title>Specifying an alphabetic range in an "if" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130412#M26605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are using SAS 9.1.3 on Mainframe z/OS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My colleague approached me asking how in an "if" statement he could check if a variable was in a range of numbers without specifying the individual members of the range. I remembered seeing a colon being used for this purpose in these forums, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; a=4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if a in (1:7) then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put 'True';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put 'False';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which my colleague then put in his code and he hasn't got back to me so I assume it is OK. This got me thinking:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any direct equivalent for an alphabetic range in an "if" statement? E.g. akin to ('A':'G') but this syntax does &lt;EM&gt;not&lt;/EM&gt; work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should be back in tomorrow if you have any questions - or better still any answers!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 17:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130412#M26605</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-05-31T17:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying an alphabetic range in an "if" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130413#M26606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... no character ranges, but for a single character you could try the RANK function ... A=65, G=71&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data x;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;length in $3;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input x :$1. @@;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;in = ifc(rank(x) in (65:71), 'YES' , 'NO');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;F G H I&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;x&amp;nbsp;&amp;nbsp;&amp;nbsp; in&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;F&amp;nbsp;&amp;nbsp;&amp;nbsp; YES&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;G&amp;nbsp;&amp;nbsp;&amp;nbsp; YES&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;H&amp;nbsp;&amp;nbsp;&amp;nbsp; NO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;I&amp;nbsp;&amp;nbsp;&amp;nbsp; NO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps&amp;nbsp; never knew that the default length of variables created with IFC is 200&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 18:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130413#M26606</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-31T18:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying an alphabetic range in an "if" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130414#M26607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amir,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is relatively straightforward, using a colon modifier in a slightly different way.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if 'A' &amp;lt;=: lastname &amp;lt;: 'C';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement selects all values for LASTNAME that begin with A or B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The colon indicates that the comparison should be made by using the number of characters in whichever string has the shorter length.&amp;nbsp; Issues to be wary of:&amp;nbsp; capitalization makes a difference, and the collating sequence is different on ASCII vs. EBCDIC systems.&amp;nbsp; Finally, note that this is different than what you were doing before.&amp;nbsp; In your numeric list, 3.5 would not be in the list.&amp;nbsp; The list of 1:7 includes the integer values only.&amp;nbsp; This character-based version is selecting differently, based on the range, not based on a list of values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 18:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130414#M26607</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-31T18:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying an alphabetic range in an "if" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130415#M26608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your answers; as usual I have learnt a lot more than the original question was posing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike: I tried looking up an opposite for the "rank" function (returns the character for a given rank) to help this kind of code work on different platforms, because I had to change the range to (193:199) for z/OS, but I could not find any - not a problem though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Astounding: Thank you for your solution and flagging the subtleties of the ranges for both numeric and character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 10:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130415#M26608</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-06-01T10:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying an alphabetic range in an "if" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130416#M26609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... opposite of RANK is BYTE.&amp;nbsp; Try (for ASCII, Windows SAS) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;do j=32 to 126;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; char_var = byte(j);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; put j 3. '|'&amp;nbsp; char_var +(-1) '|';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;portion of LOG ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 32| |&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 33|!|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 34|"|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 35|#|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 36|$|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 37|%|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 38|&amp;amp;|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 39|'|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 40|(|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 16:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130416#M26609</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-06-01T16:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying an alphabetic range in an "if" statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130417#M26610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already looked at the byte() and collate() functions that were referenced in the "See Also" section of the rank() definition, and neither struck me as being the clear opposite of&amp;nbsp; rank() - thanks for putting me right. This forum is such an education.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 16:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Specifying-an-alphabetic-range-in-an-quot-if-quot-statement/m-p/130417#M26610</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-06-01T16:49:13Z</dc:date>
    </item>
  </channel>
</rss>

