<?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 List variables with common prefix in array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376263#M90290</link>
    <description>&lt;P&gt;Listing variables with common prefix&amp;nbsp;supposed to work with "P0701--P0703"&amp;nbsp; I thought. But it doesn't run when put it in the below context.&lt;/P&gt;&lt;P&gt;Any suggestions?&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;data want; set have;
array m Code_1-Code_24; 
do over m;
if m in ("P0701","P0702","P0703","P0714","P0715","P0716", "P0717","P0718") then b=1; else 
if m in ("P0721","P0722","P0723","P0724","P0725","P0726", "P0731","P0732","P0733","P0734","P0735","P0736","P0737","P0738","P0739") then b=2; else   
if m in ("P07","P070","P071","P0710","P072","P073","P0730") then b=3; else    
if m in ("P0700","P0720") then b=4;     
end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Jul 2017 20:12:46 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2017-07-15T20:12:46Z</dc:date>
    <item>
      <title>List variables with common prefix in array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376263#M90290</link>
      <description>&lt;P&gt;Listing variables with common prefix&amp;nbsp;supposed to work with "P0701--P0703"&amp;nbsp; I thought. But it doesn't run when put it in the below context.&lt;/P&gt;&lt;P&gt;Any suggestions?&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;data want; set have;
array m Code_1-Code_24; 
do over m;
if m in ("P0701","P0702","P0703","P0714","P0715","P0716", "P0717","P0718") then b=1; else 
if m in ("P0721","P0722","P0723","P0724","P0725","P0726", "P0731","P0732","P0733","P0734","P0735","P0736","P0737","P0738","P0739") then b=2; else   
if m in ("P07","P070","P071","P0710","P072","P073","P0730") then b=3; else    
if m in ("P0700","P0720") then b=4;     
end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:12:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376263#M90290</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-15T20:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: List variables with common prefix in array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376273#M90295</link>
      <description>&lt;P&gt;Those are character strings not variables. This will work for one of your statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if m in (%macro m; %do i = 701 %to 703; "P0&amp;amp;i" %end; &lt;SPAN&gt;%do i = 714 %to 718; "P0&amp;amp;i" %end;&amp;nbsp;&lt;/SPAN&gt;%mend;%m) then b=1;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 21:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376273#M90295</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-07-15T21:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: List variables with common prefix in array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376282#M90298</link>
      <description>&lt;P&gt;Not sure what you're asking. Both of the following will satisfy your example:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array m $ Code_1-Code_24; 
  do over m;
    if m in ("P0701","P0702","P0703","P0714","P0715","P0716", "P0717","P0718") then b=1;
    else if m in ("P0721","P0722","P0723","P0724","P0725","P0726", "P0731","P0732","P0733","P0734","P0735","P0736","P0737","P0738","P0739") then b=2;
    else if m in ("P07","P070","P071","P0710","P072","P073","P0730") then b=3;
    else if m in ("P0700","P0720") then b=4;     
  end; 
run;

data want;
  set have;
  array m $ Code_1-Code_24; 
  do over m;
    if "P0701" le m le "P0718" then b=1;
    else if "P0721" le m le "P0739" then b=2;
    else if m in ("P07","P070","P071","P0710","P072","P073","P0730") then b=3;
    else if m in ("P0700","P0720") then b=4;     
  end; 
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 22:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/List-variables-with-common-prefix-in-array/m-p/376282#M90298</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-15T22:59:14Z</dc:date>
    </item>
  </channel>
</rss>

