<?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 %let statements as filename shortcuts in loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721850#M223779</link>
    <description>&lt;P&gt;Thank you so much!&amp;nbsp; This was the issue exactly.&amp;nbsp; I needed to call them outside the macro.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2021 13:26:29 GMT</pubDate>
    <dc:creator>JenniferBernard</dc:creator>
    <dc:date>2021-02-25T13:26:29Z</dc:date>
    <item>
      <title>Using %let statements as filename shortcuts in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721694#M223710</link>
      <description>&lt;P&gt;Hello all.&amp;nbsp; I have a question about using %let statements as a shortcut for full filenames.&amp;nbsp; Could someone tell me why this works:&lt;/P&gt;&lt;P&gt;%let file2005 = "/datapath/2005/filename2005";&lt;/P&gt;&lt;P&gt;But this doesn't:&lt;/P&gt;&lt;P&gt;%macro yrloop(firstyr,lastyr);&lt;/P&gt;&lt;P&gt;%do yr=&amp;amp;firstyr. %to &amp;amp;lastyr;&lt;/P&gt;&lt;P&gt;%let file&amp;amp;yr.= "/datapath/&amp;amp;yr./filename&amp;amp;yr.";&lt;/P&gt;&lt;P&gt;%end; %mend;&lt;/P&gt;&lt;P&gt;%yrloop(2005,2005);&lt;/P&gt;&lt;P&gt;How do I get the &amp;amp;yr. macro to resolve in the let statement?&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 21:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721694#M223710</guid>
      <dc:creator>JenniferBernard</dc:creator>
      <dc:date>2021-02-24T21:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using %let statements as filename shortcuts in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721697#M223711</link>
      <description>&lt;P&gt;It works fine....what do you mean it doesn't work? I suspect you're running into a scope issue, the macro variable only exists within that macro and doesn't exist outside unless you create it as a global macro variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro yrloop(firstyr,lastyr);

%do yr=&amp;amp;firstyr. %to &amp;amp;lastyr;
%global file&amp;amp;yr.;

%let file&amp;amp;yr.= "/datapath/&amp;amp;yr./filename&amp;amp;yr.";

%put &amp;amp;&amp;amp;file&amp;amp;yr.;

%end; 

%mend;

%yrloop(2000,2005);

%put &amp;amp;file2000.;

%put &amp;amp;file2005.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/331398"&gt;@JenniferBernard&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello all.&amp;nbsp; I have a question about using %let statements as a shortcut for full filenames.&amp;nbsp; Could someone tell me why this works:&lt;/P&gt;
&lt;P&gt;%let file2005 = "/datapath/2005/filename2005";&lt;/P&gt;
&lt;P&gt;But this doesn't:&lt;/P&gt;
&lt;P&gt;%macro yrloop(firstyr,lastyr);&lt;/P&gt;
&lt;P&gt;%do yr=&amp;amp;firstyr. %to &amp;amp;lastyr;&lt;/P&gt;
&lt;P&gt;%let file&amp;amp;yr.= "/datapath/&amp;amp;yr./filename&amp;amp;yr.";&lt;/P&gt;
&lt;P&gt;%end; %mend;&lt;/P&gt;
&lt;P&gt;%yrloop(2005,2005);&lt;/P&gt;
&lt;P&gt;How do I get the &amp;amp;yr. macro to resolve in the let statement?&amp;nbsp; Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 21:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721697#M223711</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-24T21:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using %let statements as filename shortcuts in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721699#M223712</link>
      <description>&lt;P&gt;Try defining the macro variable as global inside the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro yrloop(firstyr,lastyr);
    %do yr=&amp;amp;firstyr. %to &amp;amp;lastyr;
        %global file&amp;amp;yr.;
        %let file&amp;amp;yr.= "/datapath/&amp;amp;yr./filename&amp;amp;yr.";
    %end; 
%mend;
%yrloop(2005,2005);

%put &amp;amp;=file2005;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 21:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721699#M223712</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2021-02-24T21:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using %let statements as filename shortcuts in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721850#M223779</link>
      <description>&lt;P&gt;Thank you so much!&amp;nbsp; This was the issue exactly.&amp;nbsp; I needed to call them outside the macro.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 13:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-let-statements-as-filename-shortcuts-in-loop/m-p/721850#M223779</guid>
      <dc:creator>JenniferBernard</dc:creator>
      <dc:date>2021-02-25T13:26:29Z</dc:date>
    </item>
  </channel>
</rss>

