<?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: %let  Question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44330#M11730</link>
    <description>Let me make myself a little more clear.  The directory macro is indir1 and it points to c:\My Documents\.  But according to the ERROR it seems to point to a different directory.</description>
    <pubDate>Thu, 21 Jan 2010 18:50:30 GMT</pubDate>
    <dc:creator>KevinC_</dc:creator>
    <dc:date>2010-01-21T18:50:30Z</dc:date>
    <item>
      <title>%let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44323#M11723</link>
      <description>Hello Everyone,&lt;BR /&gt;
&lt;BR /&gt;
I use %let to assign a value to a variable.  But it's not working as I have hoped.  &lt;BR /&gt;
At the top portion of my program I have:&lt;BR /&gt;
&lt;BR /&gt;
%let input1='20100121_REFI1001D.xls';&lt;BR /&gt;
&lt;BR /&gt;
Down below in a proc import I have:&lt;BR /&gt;
&lt;BR /&gt;
PROC IMPORT out= test_sa_excls_addflds1&lt;BR /&gt;
                  datafile= "c:\My Documents\&amp;amp;input1"&lt;BR /&gt;
                    dbms=EXCEL REPLACE;&lt;BR /&gt;
	 SHEET='LoanListAll (Page 1)';&lt;BR /&gt;
             getnames=yes;    &lt;BR /&gt;
               scantext=yes;  &lt;BR /&gt;
                   mixed=YES;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
This is the error msg I get:&lt;BR /&gt;
ERROR: Unable to import, file c:\My Documents\&amp;amp;input1.XLS does not exist.&lt;BR /&gt;
&lt;BR /&gt;
The Excel doc is stored in c:\My Documents\20100121_REFI1001D.xls.  Can anyone tell me what I am doing wrong?&lt;BR /&gt;
Thank you for any input!!</description>
      <pubDate>Thu, 21 Jan 2010 14:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44323#M11723</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-01-21T14:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44324#M11724</link>
      <description>Why are you coding the single-quote marks in your macro variable?&lt;BR /&gt;
&lt;BR /&gt;
Suggest you add the following SAS command to increase the diagnostic output so you can see the problem, as generated:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT;&lt;BR /&gt;
&lt;BR /&gt;
But I believe that you are not seeing some warning - where the %LET is not assigning the macro variable -- as is explained in the error message.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 21 Jan 2010 15:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44324#M11724</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-21T15:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44325#M11725</link>
      <description>Should work, I mean you should get another error, because INPUT1 is in quotes and, I suppose you are trying to import&lt;BR /&gt;
&lt;BR /&gt;
c:\My Documents\20100121_REFI1001D.xls&lt;BR /&gt;
&lt;BR /&gt;
and not,&lt;BR /&gt;
&lt;BR /&gt;
c:\My Documents\'20100121_REFI1001D.xls'&lt;BR /&gt;
&lt;BR /&gt;
Aside that, INPUT1 should resolve to the value assigned previously.&lt;BR /&gt;
&lt;BR /&gt;
Is the assignment (%let) enclosed in some macro (%macro ... %mend)?&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Thu, 21 Jan 2010 15:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44325#M11725</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-21T15:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44326#M11726</link>
      <description>Hi sbb, I have switched to double-quote marks in my macro variable and added the diagnostic options.  I ran it again now I see the warning in the proc import.  Does this mean the %let didn't work?  But there was no error or warning in the step where the %let was executed.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
248  PROC IMPORT out= test_sa_excls_addflds1&lt;BR /&gt;
251              datafile= "c:\My Documents\&amp;amp;input1"&lt;BR /&gt;
WARNING: Apparent symbolic reference INPUT1 not resolved.&lt;BR /&gt;
252              dbms=EXCEL REPLACE;&lt;BR /&gt;
253              SHEET='LoanListAll (Page 1)';&lt;BR /&gt;
254              getnames=yes;     &lt;BR /&gt;
255              scantext=yes;   &lt;BR /&gt;
256              mixed=YES;&lt;BR /&gt;
257  RUN;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Unable to import, file c:\My Documents\&amp;amp;input1.XLS does not exist.</description>
      <pubDate>Thu, 21 Jan 2010 15:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44326#M11726</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-01-21T15:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44327#M11727</link>
      <description>Exactly - review your SAS program and also your expanded SAS log output in the area around the %LET statement - possibly an open comment I would suggest?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 21 Jan 2010 16:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44327#M11727</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-21T16:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44328#M11728</link>
      <description>do not quote macro var assignment.&lt;BR /&gt;
&lt;BR /&gt;
%let input1=20100121_REFI1001D.xls;&lt;BR /&gt;
&lt;BR /&gt;
see if this works.</description>
      <pubDate>Thu, 21 Jan 2010 17:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44328#M11728</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2010-01-21T17:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44329#M11729</link>
      <description>Thank you all for your valuable input!&lt;BR /&gt;
&lt;BR /&gt;
The problem was the %let was declared inside a RSUBMIT - ENDRSUBMIT.  Once I moved it outside of the Rsubmit it worked.&lt;BR /&gt;
&lt;BR /&gt;
Now I have a new question/problem:&lt;BR /&gt;
&lt;BR /&gt;
I would like to use macros for the directory as well.  The &amp;amp;input1 and &amp;amp;sheet1 macros work nicely.  But the directory macro does not work:&lt;BR /&gt;
&lt;BR /&gt;
libname indir1 'c:\My Documents\';&lt;BR /&gt;
%let input1=REFI1001D.xls;&lt;BR /&gt;
%let sheet1=LoanListAll;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PROC IMPORT out= test_sa_excls_addflds1&lt;BR /&gt;
datafile= "indir1.&amp;amp;input1"&lt;BR /&gt;
dbms=EXCEL REPLACE;&lt;BR /&gt;
SHEET=&amp;amp;sheet1;&lt;BR /&gt;
getnames=yes;     &lt;BR /&gt;
scantext=yes;   &lt;BR /&gt;
mixed=YES;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
This is what I see in the LOG:&lt;BR /&gt;
&lt;BR /&gt;
967              datafile= "indir1.&amp;amp;input1"&lt;BR /&gt;
SYMBOLGEN:  Macro variable INPUT1 resolves to REFI1001D.xls&lt;BR /&gt;
968              dbms=EXCEL REPLACE;&lt;BR /&gt;
SYMBOLGEN:  Macro variable SHEET1 resolves to LoanListAll&lt;BR /&gt;
969              SHEET=&amp;amp;sheet1;&lt;BR /&gt;
970              getnames=yes;     * variable names are in row 1 ;&lt;BR /&gt;
971              scantext=yes;   * V. 9 only;&lt;BR /&gt;
972              mixed=YES;&lt;BR /&gt;
973  RUN;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Unable to import, file C:\Documents and Settings\x90100\indir1.REFI1001D.xls does not&lt;BR /&gt;
       exist.&lt;BR /&gt;
&lt;BR /&gt;
Thank you so much for your help again!</description>
      <pubDate>Thu, 21 Jan 2010 18:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44329#M11729</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-01-21T18:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44330#M11730</link>
      <description>Let me make myself a little more clear.  The directory macro is indir1 and it points to c:\My Documents\.  But according to the ERROR it seems to point to a different directory.</description>
      <pubDate>Thu, 21 Jan 2010 18:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44330#M11730</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-01-21T18:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44331#M11731</link>
      <description>Your post reads: "...directory macro does not work".&lt;BR /&gt;
&lt;BR /&gt;
I believe some fundamental learning about SAS macro variables is important here.&lt;BR /&gt;
&lt;BR /&gt;
You have not declared a SAS %LET statement for INDIR1 which is required.  Or your DATAFILE= parameter must reference an explicit file name including complete drive/path/folder/directory information.&lt;BR /&gt;
&lt;BR /&gt;
The error message is pretty useful here - you have told SAS where to look for an input file (DATAFILE= parameter) and so there was not file by that name, as specified.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS Macro Language: Reference&lt;BR /&gt;
Macro Variables, Introduction to Macro Variables&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293823.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293823.htm&lt;/A&gt;</description>
      <pubDate>Thu, 21 Jan 2010 18:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44331#M11731</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-21T18:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: %let  Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44332#M11732</link>
      <description>sbb,&lt;BR /&gt;
&lt;BR /&gt;
Thank you for reminding me.  I have made changes to my code and now it works fine:&lt;BR /&gt;
&lt;BR /&gt;
%let indir1= c:\My Documents\;&lt;BR /&gt;
%let input1=REFI1001D.xls;&lt;BR /&gt;
%let sheet1=LoanListAll;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
1043  PROC IMPORT out= test_sa_excls_addflds1&lt;BR /&gt;
1045              datafile= "&amp;amp;indir1&amp;amp;input1"&lt;BR /&gt;
SYMBOLGEN:  Macro variable INDIR1 resolves to c:\My Documents\&lt;BR /&gt;
SYMBOLGEN:  Macro variable INPUT1 resolves to REFI1001D.xls&lt;BR /&gt;
1046              dbms=EXCEL REPLACE;&lt;BR /&gt;
SYMBOLGEN:  Macro variable SHEET1 resolves to LoanListAll&lt;BR /&gt;
1047              SHEET=&amp;amp;sheet1;&lt;BR /&gt;
1048              getnames=yes;    &lt;BR /&gt;
1049              scantext=yes;   &lt;BR /&gt;
1050              mixed=YES;&lt;BR /&gt;
1051  RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you again!!</description>
      <pubDate>Thu, 21 Jan 2010 19:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-Question/m-p/44332#M11732</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2010-01-21T19:09:22Z</dc:date>
    </item>
  </channel>
</rss>

