<?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: in function for a list of strings within do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397261#M96003</link>
    <description>&lt;P&gt;Or, use some base functions - this would likely be considered old fashioned. I'm sure a PRX solution is better but I avoid those like the plague.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Check if first character is E&lt;/P&gt;
&lt;P&gt;2. Check if next two characters are in 10:90&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if char(character_variable, 1) = 'E' and input(substr(character_variable, 2, 2), 8.) in (10:90) then do ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Sep 2017 20:54:20 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-09-19T20:54:20Z</dc:date>
    <item>
      <title>in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397236#M95991</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to simiply my program.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this program and it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;=====================================================&lt;/P&gt;&lt;P&gt;data new_data;&lt;BR /&gt;set old_data;&lt;BR /&gt;array old_code[*] old_code1-old_code25;&lt;BR /&gt;array new_code[*] new_code1-new_code25;&lt;BR /&gt;do i = 1 to 25;&lt;BR /&gt;old_code[i]= compress(old_code[i], '.') ;&lt;BR /&gt;if old_code[i] in: ('E10','E11','E12','E13','E14') then new_code[i]=1;&lt;BR /&gt;else new_code[i]=0;&lt;BR /&gt;end;&lt;BR /&gt;output;&lt;/P&gt;&lt;P&gt;======================================================&lt;/P&gt;&lt;P&gt;I thought that I could replace&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;('E10','E11','E12','E13','E14')&amp;nbsp; with ('E40':'E14'). &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I got an error message:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,&lt;BR /&gt;a datetime constant, a missing value, iterator, (, ), ','."&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my real dataset, I have to list more like E10 to E90. &amp;nbsp;So, it would be nice if there is a way to make programming easy.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I appreciate your suggestions.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Oh, and for the above example, I understand that 'E10' following in: means any string starting with E10. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Am I correct?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Yoko&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 19:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397236#M95991</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-09-19T19:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397242#M95994</link>
      <description>&lt;P&gt;If you're criteria is matching the first three characters, then substr the first three characters and make your comparison. Unfortunately I think you're stuck typing it out because the list is character and ranges for characters aren't a good idea in my experience.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 19:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397242#M95994</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-19T19:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397248#M95998</link>
      <description>&lt;P&gt;You can use a macro to generate the list. &amp;nbsp;The following step llustrates:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
   %macro e; %do i = 10 %to 90; "E&amp;amp;i" %end; %mend; 
   x = 'E20';
   if x in (%e) then put 'Yes 20';
   x = 'E201';
   if x in (%e) then put 'no 201';
run;   
   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 20:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397248#M95998</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-09-19T20:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397259#M96001</link>
      <description>&lt;P&gt;Can't test it now, but maybe creating a format helps.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
   InValue narf
      'E10'-'E90' = 1
      Other = 0;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;In the datastep: new_code[i] = input(old_code[i], narf.);&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 20:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397259#M96001</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-09-19T20:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397261#M96003</link>
      <description>&lt;P&gt;Or, use some base functions - this would likely be considered old fashioned. I'm sure a PRX solution is better but I avoid those like the plague.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Check if first character is E&lt;/P&gt;
&lt;P&gt;2. Check if next two characters are in 10:90&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if char(character_variable, 1) = 'E' and input(substr(character_variable, 2, 2), 8.) in (10:90) then do ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2017 20:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397261#M96003</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-19T20:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397403#M96043</link>
      <description>Thank you for your reply!</description>
      <pubDate>Wed, 20 Sep 2017 12:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397403#M96043</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-09-20T12:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397569#M96094</link>
      <description>Thank you for your reply!</description>
      <pubDate>Wed, 20 Sep 2017 18:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397569#M96094</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-09-20T18:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: in function for a list of strings within do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397577#M96097</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152732"&gt;@Yoko&lt;/a&gt;&amp;nbsp;if your problem is solved&amp;nbsp;please mark the correct solution as the answer/solution.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 19:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/in-function-for-a-list-of-strings-within-do-loop/m-p/397577#M96097</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-20T19:14:29Z</dc:date>
    </item>
  </channel>
</rss>

