<?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: Subset '30'-'33' (character variable) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235912#M55178</link>
    <description>&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;where food_type between '30' and '33'; &amp;nbsp; *or where &amp;nbsp;'30'&amp;lt;=food_type&amp;lt;='33';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Nov 2015 16:40:36 GMT</pubDate>
    <dc:creator>slchen</dc:creator>
    <dc:date>2015-11-22T16:40:36Z</dc:date>
    <item>
      <title>Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235894#M55171</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Iam using SAS 7.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am quite new to SAS, so pardon if my question sounds basic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have a range of character variable.&lt;/P&gt;
&lt;P&gt;EG:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Food_Type&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'24',&amp;nbsp; '30' , '31', '32', '33', '34'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only want to select the data for Food_Type = '30' - '33'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SAS Code 1:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;set test;&lt;/P&gt;
&lt;P&gt;where Food_Type in ('30' -'33');&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SAS Code 2:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;set test;&lt;/P&gt;
&lt;P&gt;where Food_Type in ('30') or Food_Type in ('31')&amp;nbsp;or Food_Type in ('32')&amp;nbsp;or Food_Type in ('33') ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Code 1 doesn't work but SAS code 2 does. However, it is very tedious to type out all the Food_Type values I want. Is there a faster way I could select '30' - '33'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2015 08:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235894#M55171</guid>
      <dc:creator>apple</dc:creator>
      <dc:date>2015-11-22T08:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235898#M55172</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where '30' LE Food_Type LE '33';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.... Good Luck...!!!&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2015 09:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235898#M55172</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-11-22T09:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235912#M55178</link>
      <description>&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;where food_type between '30' and '33'; &amp;nbsp; *or where &amp;nbsp;'30'&amp;lt;=food_type&amp;lt;='33';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2015 16:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235912#M55178</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-11-22T16:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235925#M55179</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where food_type in ('24',  '30' , '31', '32', '33', '34')
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if only dealing with digits don't use ranges with character&amp;nbsp;variables as you might get unexpected results like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if '99'&amp;gt;'100' then put '99&amp;gt;100';
  else put '99&amp;lt;=100';
run;

Result in log:
99&amp;gt;100&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Nov 2015 21:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235925#M55179</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-22T21:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235932#M55180</link>
      <description>&lt;P&gt;While you have many solutions that will work with the example you gave, heed Patrick's warning. &amp;nbsp;There are many cases where you would run into trouble. &amp;nbsp;For example, if your FOOD_TYPE variable is actually 3 characters long, the solutions proposed would also include '301'. &amp;nbsp;That falls within the range of "30" to "33".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once your first digit can change, the problems get worse. &amp;nbsp;For example, if you tried this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where ('39' &amp;lt;= food_type &amp;lt;= '41');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That range also includes a few values you might not want, such as "4" and either "3F' or "4F" (depends on the operating system).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will get by in this particular case, but you will need to understand how SAS compares character strings to be safe in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2015 23:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235932#M55180</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-11-22T23:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235942#M55181</link>
      <description>&lt;P&gt;This works even when your first digit changes:&lt;/P&gt;
&lt;P&gt;where &amp;nbsp; 30 &amp;lt;=input(&lt;SPAN&gt;Food_Type, 3.&lt;/SPAN&gt;) &amp;lt;= 100&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2015 07:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235942#M55181</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-11-23T07:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Subset '30'-'33' (character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235964#M55183</link>
      <description>&lt;P&gt;This selects the range, including 30 and 33:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;where food_type between 30 and 33;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2015 12:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subset-30-33-character-variable/m-p/235964#M55183</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-11-23T12:12:54Z</dc:date>
    </item>
  </channel>
</rss>

