<?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 Help with &amp;amp;&amp;amp;var&amp;amp;i? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408052#M99506</link>
    <description>&lt;P&gt;I've spent hours on this, but it will not work when I try to run it as a dataset. What I am trying to do is read in multiple datasets with the same ending, but different prefixes. Such as:&lt;/P&gt;&lt;P&gt;d170726_1 d170726_2 d170822 d170925&lt;/P&gt;&lt;P&gt;They are datasets within the same fiscal quarter, so I want to combine them into one quarter overall, but first I must run some logic. It is much more simpler to do this with a macro since this will be a continuing issue for the entire year since the data comes in waves. I want to make the process generalizable, but there needs to be some sorting, etc. before the merging. So... I placed these names in a .txt file using:&lt;/P&gt;&lt;P&gt;data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;null&lt;/EM&gt;; length dsn $9. ; infile "&amp;amp;proj.&amp;amp;&lt;EM&gt;sp&lt;/EM&gt;.CY2017&amp;amp;&lt;EM&gt;sp&lt;/EM&gt;.datasets.txt" truncover; input @1 dsn $9. ;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;i+1;
ii = left(put(i,2.));
call symput('n',ii);
call symput('dsn'||ii,left(dsn));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;when run %put&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;all&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;, the codes show: dsn1 = 1232_test, dsn2 = 42521_1_test, etc.&lt;/P&gt;&lt;P&gt;Cool great. I use this in the code data&amp;amp;year..&amp;amp;&amp;amp;dsn&amp;amp;i._mst_tbl... And these are my results &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt;&lt;/P&gt;&lt;P&gt;d170726_1 WARNING: Apparent symbolic reference DSN1_MST_TBL not resolved. WARNING: Apparent symbolic reference DSN1_CPT_CODE not resolved. WARNING: data2017.&amp;amp;dsn1_cpt_code does not exist&lt;/P&gt;&lt;P&gt;Please help &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; What am I doing wrong? I'm going insane.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2017 14:30:19 GMT</pubDate>
    <dc:creator>friedtukeywings</dc:creator>
    <dc:date>2017-10-27T14:30:19Z</dc:date>
    <item>
      <title>Help with &amp;&amp;var&amp;i?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408052#M99506</link>
      <description>&lt;P&gt;I've spent hours on this, but it will not work when I try to run it as a dataset. What I am trying to do is read in multiple datasets with the same ending, but different prefixes. Such as:&lt;/P&gt;&lt;P&gt;d170726_1 d170726_2 d170822 d170925&lt;/P&gt;&lt;P&gt;They are datasets within the same fiscal quarter, so I want to combine them into one quarter overall, but first I must run some logic. It is much more simpler to do this with a macro since this will be a continuing issue for the entire year since the data comes in waves. I want to make the process generalizable, but there needs to be some sorting, etc. before the merging. So... I placed these names in a .txt file using:&lt;/P&gt;&lt;P&gt;data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;null&lt;/EM&gt;; length dsn $9. ; infile "&amp;amp;proj.&amp;amp;&lt;EM&gt;sp&lt;/EM&gt;.CY2017&amp;amp;&lt;EM&gt;sp&lt;/EM&gt;.datasets.txt" truncover; input @1 dsn $9. ;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;i+1;
ii = left(put(i,2.));
call symput('n',ii);
call symput('dsn'||ii,left(dsn));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;when run %put&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;all&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;, the codes show: dsn1 = 1232_test, dsn2 = 42521_1_test, etc.&lt;/P&gt;&lt;P&gt;Cool great. I use this in the code data&amp;amp;year..&amp;amp;&amp;amp;dsn&amp;amp;i._mst_tbl... And these are my results &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt;&lt;/P&gt;&lt;P&gt;d170726_1 WARNING: Apparent symbolic reference DSN1_MST_TBL not resolved. WARNING: Apparent symbolic reference DSN1_CPT_CODE not resolved. WARNING: data2017.&amp;amp;dsn1_cpt_code does not exist&lt;/P&gt;&lt;P&gt;Please help &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; What am I doing wrong? I'm going insane.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 14:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408052#M99506</guid>
      <dc:creator>friedtukeywings</dc:creator>
      <dc:date>2017-10-27T14:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with &amp;&amp;var&amp;i?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408058#M99507</link>
      <description>Hi:&lt;BR /&gt;  You do not show enough code. For example, you do not show how &amp;amp;proj, &amp;amp;sp,  &amp;amp;I or &amp;amp;year is created. You only show CALL SYMPUT for &amp;amp;dsn.&lt;BR /&gt;&lt;BR /&gt;  The warning in the LOG is trying to tell you that something about your indirect reference is specified incorrectly. An indirect reference is when you use multiple ampersands to delay the resolution for part of a macro variable reference while you another part of the macro variable gets resolved. Then due to the way that macro variables are scanned and resolved, multiple ampersands cause the Macro processor to "hold" and "rescan" a reference with multiple &amp;amp;&amp;amp; until all the resolution and substitution are finished.&lt;BR /&gt;&lt;BR /&gt;  For a simple example, please refer to this paper: &lt;A href="https://support.sas.com/resources/papers/proceedings13/120-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/120-2013.pdf&lt;/A&gt; on page 10-11 at the discussion of indirect reference in regard to the macro variable reference &amp;amp;&amp;amp;muppet&amp;amp;num.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Fri, 27 Oct 2017 14:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408058#M99507</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-10-27T14:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with &amp;&amp;var&amp;i?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408059#M99508</link>
      <description>&lt;P&gt;I'm not sure you showed us what you want this to resolve into:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;&amp;amp;dsn&amp;amp;i._mst_tbl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I'll assume it should take the value &amp;amp;DSN1 (then &amp;amp;DSN2, then &amp;amp;DSN3, etc.), and append _mst_tbl at the end.&amp;nbsp; If that's the intent, a small change should take care of things&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;amp;&amp;amp;dsn&amp;amp;i.._mst_tbl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With two dots in the middle, the first one delimits &amp;amp;i, then the second one delimits &amp;amp;DSN1.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 14:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408059#M99508</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-27T14:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with &amp;&amp;var&amp;i?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408061#M99509</link>
      <description>&lt;P&gt;I am sorry,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is set within a large macro such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro sashelp (year =, ms_tbl =);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which then corresponds to:&lt;/P&gt;&lt;P&gt;%sashelp (2015, garden) and so forth.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Edit] Forgot to answer this, the &amp;amp;proj and &amp;amp;_sp_ macro variables are just the path of the file.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 14:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408061#M99509</guid>
      <dc:creator>friedtukeywings</dc:creator>
      <dc:date>2017-10-27T14:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with &amp;&amp;var&amp;i?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408062#M99510</link>
      <description>&lt;P&gt;My apologies. Yes, the dataset should resolve to the dsn1, dsn2, and so forth variables which should contain the actual dataset name so that dsn1 the 1st dataset listed in the .txt file.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 14:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408062#M99510</guid>
      <dc:creator>friedtukeywings</dc:creator>
      <dc:date>2017-10-27T14:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with &amp;&amp;var&amp;i?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408065#M99511</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What am I doing wrong?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Perhaps it is that you are making your program too complicated?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Someone already has given you the answer that you need to add another period to mark the end of the &amp;amp;DSNx macro reference since you need to resolve two different macro variables in front of the fixed text.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;&amp;amp;dsn&amp;amp;i.._MST_TBL &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;That should have been pretty clear from the&amp;nbsp;warning messages&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;WARNING: Apparent symbolic reference DSN1_MST_TBL not resolved.
WARNING: Apparent symbolic reference DSN1_CPT_CODE not resolved.&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;that you got.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But if you just expand your code to make the steps a little clearer it will be easier for both you and SAS to figure out what you are doing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 to &amp;amp;nobs ;
....
%let basename=&amp;amp;&amp;amp;dsn&amp;amp;i ;
%let master=&amp;amp;basename._MST_TBL ;
%let cptfile=&amp;amp;basename._CPT_CODE;
data &amp;amp;master ;
  set &amp;amp;cptfile ;
  ....

%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 14:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-amp-amp-var-amp-i/m-p/408065#M99511</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-27T14:56:18Z</dc:date>
    </item>
  </channel>
</rss>

