<?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: Find function with macro variable and arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/507000#M135984</link>
    <description>&lt;P&gt;From what you have posted so far, the program would be easier with no macro variables at all.&amp;nbsp; How do they make anything easier?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2018 20:01:30 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-10-23T20:01:30Z</dc:date>
    <item>
      <title>Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506916#M135933</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know how to use the find function with arrays.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have :&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;
	y1 = find(var, trim("&amp;amp;yes1"), 'i');
	y2 = find(var, trim("&amp;amp;yes2"), 'i');
	y3 = find(var, trim("&amp;amp;yes3"), 'i');&lt;BR /&gt;
	n1 = find(var, trim("&amp;amp;no1"), 'i');
	n2 = find(var, trim("&amp;amp;no2"), 'i');
	n3 = find(var, trim("&amp;amp;no3"), 'i');
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to optimize my program and do something like this :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; set have;
	array y {*} y1-y3;
	do i = 1 to dim(y);
        y(i) = find(var, trim("&amp;amp;yes(i)"), 'i'); 
	end;

	array n {*} n1-n3;
	do i = 1 to dim(n);
        n(i) = find(var, trim("&amp;amp;no(i)"), 'i');
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 16:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506916#M135933</guid>
      <dc:creator>dera</dc:creator>
      <dc:date>2018-10-23T16:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506921#M135936</link>
      <description>&lt;P&gt;So apparently you have already created macro variables &amp;amp;yes1 &amp;amp;yes2 &amp;amp;yes3 and &amp;amp;no1 &amp;amp;no2 &amp;amp;no3. Then your loops would need this syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;y(i) = find(var, trim("&amp;amp;&amp;amp;yes&amp;amp;i"), 'i'); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Oct 2018 16:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506921#M135936</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-23T16:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506942#M135950</link>
      <description>&lt;P&gt;What do you mean by "optimize my program" ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have created your macro variables carefully (by removing leading and trailing blanks) you can make the program run faster by removing the TRIM function.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 17:43:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506942#M135950</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-23T17:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506974#M135966</link>
      <description>I mean that if I want to make it easier if I decide to add more macro variable. Paige Miller understood what I am looking for but his code does not work. Do you have idea?</description>
      <pubDate>Tue, 23 Oct 2018 18:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506974#M135966</guid>
      <dc:creator>dera</dc:creator>
      <dc:date>2018-10-23T18:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506980#M135969</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236159"&gt;@dera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I mean that if I want to make it easier if I decide to add more macro variable. Paige Miller understood what I am looking for but his code does not work. Do you have idea?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We can't help you if the only information you give us is "does not work". Please explain. Please show us the SASLOG. Give us information.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506980#M135969</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-23T18:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506981#M135970</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to 3;
    y(&amp;amp;i) = find(var, trim("&amp;amp;&amp;amp;yes&amp;amp;i"), 'i'); 
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I am starting to think that there must be easier ways to do this than mixing arrays and macro variables, but since we don't really know what you are doing, it's hard to advise.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 18:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/506981#M135970</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-23T18:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/507000#M135984</link>
      <description>&lt;P&gt;From what you have posted so far, the program would be easier with no macro variables at all.&amp;nbsp; How do they make anything easier?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 20:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/507000#M135984</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-23T20:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with macro variable and arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/507060#M136015</link>
      <description>&lt;P&gt;If you insist on using macro-variables, then try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; set have;
	array y {*} y1-y3;
	do i = 1 to dim(y);
          y(i) = find(var, symget(cats('yes', i)), 'i'); 
	end;

	array n {*} n1-n3;
	do i = 1 to dim(n);
          n(i) = find(var, symget(cats('no', i)), 'i');
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Properly created macro-variable don't have trailing blanks.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 06:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-macro-variable-and-arrays/m-p/507060#M136015</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-10-24T06:57:42Z</dc:date>
    </item>
  </channel>
</rss>

