<?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: Using two macro variables with multiple &amp;amp; in sas macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439632#M109733</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide some example datasets in the form of data steps that can help us reproduce the problem&lt;/P&gt;
&lt;P&gt;and tell us exactly he results you obtain. What is the log saying ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have macrovariables foo_1, foo_2, ..., foo_n and a counter &amp;amp;i., the way to resolve them is &amp;amp;&amp;amp;foo_&amp;amp;i..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At first glance, your program seems correct except that there is a space after "fund." in your create table instruction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you really need to create separate tables for each fund, time ? You can probably achieve your goal using&lt;/P&gt;
&lt;P&gt;by group processing.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 09:05:53 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-02-23T09:05:53Z</dc:date>
    <item>
      <title>Using two macro variables with multiple &amp; in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439610#M109724</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I am having difficulty in quoting macro variables in my macro code.&lt;/P&gt;&lt;P&gt;Here is a brief example of my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null;&lt;BR /&gt;set data1;&lt;BR /&gt;call symputx('fund'||left(_n_),crsp_portno);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null;&lt;BR /&gt;set data2;&lt;BR /&gt;call symputx('time'||left(_n_),date);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro name;&lt;/P&gt;&lt;P&gt;%local i;&lt;BR /&gt;%local j;&lt;/P&gt;&lt;P&gt;%do i=1 %to 2;&lt;BR /&gt;%do j=1 %to 2;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table fund. f&amp;amp;&amp;amp;fund&amp;amp;i&amp;amp;&amp;amp;time&amp;amp;j._raw as&lt;BR /&gt;select * from somewhere&lt;BR /&gt;where crsp_portno=&amp;amp;&amp;amp;fund&amp;amp;i&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Espeically, I am having trouble with using the expression&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;f&amp;amp;&amp;amp;fund&amp;amp;i&amp;amp;&amp;amp;time&amp;amp;j._raw&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was expecting&amp;nbsp;this&amp;nbsp;code&amp;nbsp;plays like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;f&amp;amp;&amp;amp;fund&amp;amp;i&amp;amp;&amp;amp;time&amp;amp;j._raw&lt;/P&gt;&lt;P&gt;-&amp;gt;&lt;/P&gt;&lt;P&gt;f&amp;amp;fund1&amp;amp;time1._raw&lt;/P&gt;&lt;P&gt;-&amp;gt;&lt;/P&gt;&lt;P&gt;f100000120120331_raw&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this way.&lt;/P&gt;&lt;P&gt;(Those values that were assigned to &amp;amp;fundi and &amp;amp;timej are all numeric with 7 or 8 digits)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it seems that I have poor understanding in using multiple &amp;amp;.&lt;/P&gt;&lt;P&gt;Could anyone give an idea for this?&lt;/P&gt;&lt;P&gt;Thanks for reading my thread.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 07:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439610#M109724</guid>
      <dc:creator>Sejin</dc:creator>
      <dc:date>2018-02-23T07:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using two macro variables with multiple &amp; in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439629#M109731</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190977"&gt;@Sejin&lt;/a&gt;&amp;nbsp;It's highly likely not a good design decision to create that many SAS tables. Not sure what you're trying to achieve but an index or something in this direction would eventually be a better approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But to answer your question: Each iteration&amp;nbsp;for resolving the macro variable will consume one dot. So for your result to end-up&amp;nbsp;with what you're after, you need at least two such dots (for the two ampersand to get resolved).&lt;/P&gt;
&lt;PRE&gt;f&amp;amp;&amp;amp;fund&amp;amp;i&amp;amp;&amp;amp;time&amp;amp;j.._raw&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the call symputx() bit code as below would be cleaner:&lt;/P&gt;
&lt;PRE&gt;call symputx(cats('fund',put(_n_,f5.)),crsp_portno);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 09:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439629#M109731</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-02-23T09:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using two macro variables with multiple &amp; in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439632#M109733</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide some example datasets in the form of data steps that can help us reproduce the problem&lt;/P&gt;
&lt;P&gt;and tell us exactly he results you obtain. What is the log saying ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have macrovariables foo_1, foo_2, ..., foo_n and a counter &amp;amp;i., the way to resolve them is &amp;amp;&amp;amp;foo_&amp;amp;i..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At first glance, your program seems correct except that there is a space after "fund." in your create table instruction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you really need to create separate tables for each fund, time ? You can probably achieve your goal using&lt;/P&gt;
&lt;P&gt;by group processing.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 09:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-two-macro-variables-with-multiple-amp-in-sas-macro/m-p/439632#M109733</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-02-23T09:05:53Z</dc:date>
    </item>
  </channel>
</rss>

