<?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: Cannot get my macro variable working in a PROC IMPORT? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63103#M13713</link>
    <description>Or the slightly more intuitive version&lt;BR /&gt;
&lt;BR /&gt;
%macro test;&lt;BR /&gt;
%let data_folder = c:\;&lt;BR /&gt;
libname test "&amp;amp;data_folder"; /* No period here */&lt;BR /&gt;
/* Two periods in next line, following a macro variable */&lt;BR /&gt;
/* resolves to a single period.                                   */&lt;BR /&gt;
proc import datafile = "&amp;amp;data_folder..test.xls"&lt;BR /&gt;
out = test.test1 dbms=excel replace;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
%test;</description>
    <pubDate>Mon, 01 Mar 2010 17:43:52 GMT</pubDate>
    <dc:creator>Paige</dc:creator>
    <dc:date>2010-03-01T17:43:52Z</dc:date>
    <item>
      <title>Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63096#M13706</link>
      <description>Hi, &lt;BR /&gt;
&lt;BR /&gt;
I am at a loss as to why my macro variable DATA_FOLDER does not work &lt;BR /&gt;
with my proc import. I have tried various combinations using a " and a &lt;BR /&gt;
' defining the variable and in the proc import but any combination I &lt;BR /&gt;
seem to use does not work. Here I am using single quotes defining the &lt;BR /&gt;
macro variable and no quotes around the usage of the variable. &lt;BR /&gt;
&lt;BR /&gt;
6721  %macro test; &lt;BR /&gt;
6722  %let data_folder = 'c:\'; &lt;BR /&gt;
6723  libname test &amp;amp;data_folder.; &lt;BR /&gt;
6724  proc import &lt;BR /&gt;
6725  datafile = &amp;amp;data_folder.'test.xls' &lt;BR /&gt;
6726  out = test.test1 dbms=excel replace; &lt;BR /&gt;
6727  run; &lt;BR /&gt;
6728  %mend test; &lt;BR /&gt;
6729  %test; &lt;BR /&gt;
MPRINT(TEST):   libname test 'c:\'; &lt;BR /&gt;
NOTE: Libname TEST refers to the same physical library as ACR. &lt;BR /&gt;
NOTE: Libref TEST was successfully assigned as follows: &lt;BR /&gt;
      Engine:        V9 &lt;BR /&gt;
      Physical Name: c:\ &lt;BR /&gt;
MPRINT(TEST):   proc import datafile = 'c:\''test.xls' out = &lt;BR /&gt;
test.test1 dbms=excel replace; &lt;BR /&gt;
MPRINT(TEST):   AEXC; &lt;BR /&gt;
MPRINT(TEST):   run; &lt;BR /&gt;
ERROR: Unable to import, file c:\'test.xls does not exist. &lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors. &lt;BR /&gt;
NOTE: PROCEDURE IMPORT used (Total process time): &lt;BR /&gt;
      real time           0.04 seconds &lt;BR /&gt;
      cpu time            0.03 seconds</description>
      <pubDate>Mon, 01 Mar 2010 14:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63096#M13706</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-03-01T14:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63097#M13707</link>
      <description>As revealed in your log, you have stray tick/quotation marks coded.  You should not need to use them in your code.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 01 Mar 2010 14:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63097#M13707</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-01T14:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63098#M13708</link>
      <description>While you didn't say what operating system you use, I will assume that it is some version of Windows, in which case you wouldn't put c:\ in any quotes whatsoever in macro variable data_folder.&lt;BR /&gt;
&lt;BR /&gt;
After you fix that, in the PROC IMPORT statement, you again have quotes in the wrong places. It should look like:&lt;BR /&gt;
&lt;BR /&gt;
proc import datafile="&amp;amp;data_folder\test.xls" ...&lt;BR /&gt;
&lt;BR /&gt;
You don't want quotes anywhere in the interior of the datefile=" ", you just want quotes at the beginning and end of whatever text string represents your file.</description>
      <pubDate>Mon, 01 Mar 2010 14:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63098#M13708</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-03-01T14:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63099#M13709</link>
      <description>Scott, &lt;BR /&gt;
&lt;BR /&gt;
I did remove the quotes but them it had a problem with my drive letter! &lt;BR /&gt;
&lt;BR /&gt;
Lee</description>
      <pubDate>Mon, 01 Mar 2010 14:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63099#M13709</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-03-01T14:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63100#M13710</link>
      <description>Paige,&lt;BR /&gt;
&lt;BR /&gt;
When I removed quotes it had a problem with e:\ so I am not sure how I pass the drive location to my code?&lt;BR /&gt;
&lt;BR /&gt;
yes sorry its windows...&lt;BR /&gt;
&lt;BR /&gt;
Lee</description>
      <pubDate>Mon, 01 Mar 2010 14:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63100#M13710</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-03-01T14:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63101#M13711</link>
      <description>Lee, please show us your code and the SASLOG, and we will be able to help.&lt;BR /&gt;
&lt;BR /&gt;
Saying "it had a problem" doesn't allow us to provide any help at all.</description>
      <pubDate>Mon, 01 Mar 2010 15:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63101#M13711</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-03-01T15:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63102#M13712</link>
      <description>Try this:&lt;BR /&gt;
 %macro test; &lt;BR /&gt;
 %let data_folder = c:\; &lt;BR /&gt;
 libname test "&amp;amp;data_folder."; &lt;BR /&gt;
 proc import &lt;BR /&gt;
datafile = "&amp;amp;data_folder.test.xls" &lt;BR /&gt;
 out = test.test1 dbms=excel replace; &lt;BR /&gt;
 run; &lt;BR /&gt;
 %mend test; &lt;BR /&gt;
%test;</description>
      <pubDate>Mon, 01 Mar 2010 15:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63102#M13712</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-03-01T15:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63103#M13713</link>
      <description>Or the slightly more intuitive version&lt;BR /&gt;
&lt;BR /&gt;
%macro test;&lt;BR /&gt;
%let data_folder = c:\;&lt;BR /&gt;
libname test "&amp;amp;data_folder"; /* No period here */&lt;BR /&gt;
/* Two periods in next line, following a macro variable */&lt;BR /&gt;
/* resolves to a single period.                                   */&lt;BR /&gt;
proc import datafile = "&amp;amp;data_folder..test.xls"&lt;BR /&gt;
out = test.test1 dbms=excel replace;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend test;&lt;BR /&gt;
%test;</description>
      <pubDate>Mon, 01 Mar 2010 17:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63103#M13713</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-03-01T17:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63104#M13714</link>
      <description>Hi:&lt;BR /&gt;
  As Paige suggests, seeing your LOG would be most helpful. One suggestion...are you sure that your E drive is available??? For example, review this SAS log:&lt;BR /&gt;
[pre]&lt;BR /&gt;
192  %let data_folder = e:\;&lt;BR /&gt;
193  libname test "&amp;amp;data_folder.";&lt;BR /&gt;
NOTE: Libref TEST was successfully assigned as follows:&lt;BR /&gt;
      Engine:        V9&lt;BR /&gt;
      Physical Name: e:\&lt;BR /&gt;
                                      &lt;BR /&gt;
194  %let data_folder = j:\;&lt;BR /&gt;
195  libname test "&amp;amp;data_folder.";&lt;BR /&gt;
NOTE: Library TEST does not exist.&lt;BR /&gt;
        &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
 On my windows system, I DO have an E: drive, but I do NOT have a J: drive. &lt;BR /&gt;
 &lt;BR /&gt;
  As a general rule of thumb, it is a bad idea to "pre-quote" your macro variables in the %LET statement. Macro variables are just character strings and quotes belong in the statements where you USE the macro variables.&lt;BR /&gt;
 &lt;BR /&gt;
  For example in these two %LET statements below the second (unquoted) value for 16 is the correct usage:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let age = '16';&lt;BR /&gt;
%let age = 16;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                       &lt;BR /&gt;
 As you can see from this LOG, with quotes inside &amp;amp;AGE, my WHERE statement is incorrect:&lt;BR /&gt;
[pre]&lt;BR /&gt;
196  %let age = '16';&lt;BR /&gt;
197  proc print data=sashelp.class;&lt;BR /&gt;
198    title "1) Wrong: Students who are &amp;amp;age";&lt;BR /&gt;
199    where age = &amp;amp;age;&lt;BR /&gt;
ERROR: WHERE clause operator requires compatible variables.&lt;BR /&gt;
200  run;&lt;BR /&gt;
                 &lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
201&lt;BR /&gt;
202  %let age = 16;&lt;BR /&gt;
&lt;BR /&gt;
                   &lt;BR /&gt;
203  proc print data=sashelp.class;&lt;BR /&gt;
204    title "2) Right: Students who are &amp;amp;age";&lt;BR /&gt;
205    where age = &amp;amp;age;&lt;BR /&gt;
206  run;&lt;BR /&gt;
                &lt;BR /&gt;
NOTE: There were 1 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;
      WHERE age=16;&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.18 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
                                                                      &lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                         &lt;BR /&gt;
This paper is a good introduction to Macro processing concepts. &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt;&lt;BR /&gt;
              &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 01 Mar 2010 19:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63104#M13714</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-01T19:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get my macro variable working in a PROC IMPORT?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63105#M13715</link>
      <description>Thanks everyone for your input. It is working now. I will include a little log  next time I refer to an error (sorry). I am still not 100% what I did wrong as I got myself really confused but its a mixture of putting quotes everywhere, rushing to meet deadlines and going through a big learning curve.&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your support and I will take time out to read the recommended reading.&lt;BR /&gt;
&lt;BR /&gt;
:-)&lt;BR /&gt;
&lt;BR /&gt;
Lee</description>
      <pubDate>Tue, 02 Mar 2010 11:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-my-macro-variable-working-in-a-PROC-IMPORT/m-p/63105#M13715</guid>
      <dc:creator>LeeJenson</dc:creator>
      <dc:date>2010-03-02T11:57:50Z</dc:date>
    </item>
  </channel>
</rss>

