<?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: How to use macro variable in infile statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/350102#M81332</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;Does the same work accessing/importing a URL?&amp;nbsp; I want to import a table from a url that has dynamic characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I have below is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var1=2017;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var2='NC'; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var9='Cary'; &lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;filename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; myfile &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;url&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"&lt;A href="http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=" target="_blank"&gt;http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=&lt;/A&gt;&lt;STRONG&gt;&amp;amp;var1&lt;/STRONG&gt;&amp;amp;task=0&amp;amp;state=&lt;STRONG&gt;&amp;amp;var2&lt;/STRONG&gt;&amp;amp;place=&lt;STRONG&gt;&amp;amp;var9&lt;/STRONG&gt;"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;lrecl&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;32767&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;here is the original url.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;filename myfile url "&lt;A href="http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=2017&amp;amp;task=0&amp;amp;state=NC&amp;amp;place=Cary" target="_blank"&gt;http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=2017&amp;amp;task=0&amp;amp;state=NC&amp;amp;place=Cary&lt;/A&gt;" lrecl=32767;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2017 17:32:49 GMT</pubDate>
    <dc:creator>tobyfarms</dc:creator>
    <dc:date>2017-04-14T17:32:49Z</dc:date>
    <item>
      <title>How to use macro variable in infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/21223#M3393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the first time I write a code with macro and I get stucked with seemingly very easy step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro readdata(yrmo=);&lt;/P&gt;&lt;P&gt;data &amp;amp;yrmo;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile 'C:\Users\XXX\&amp;amp;yrmo';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input cusip&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $ 1-8 name $ 9-40 date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; issue_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maturity_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trader_matrix $ flat_prc acc_int coupon&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield &lt;/P&gt;&lt;P&gt;duration amount_out&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Moody_rat SP_rat callability $ call_prc putability $ put_prc ret ind_code &lt;/P&gt;&lt;P&gt;Fitch_rat index_flag convexity Duff_Phelps;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%readdata(yrmo = Y0173);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code gives me an error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: Physical file does not exist, C:\XXX\&amp;amp;yrmo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, the file actually exists and if I replace &amp;amp;yrmo with Y0173, the code works fine.&lt;/P&gt;&lt;P&gt;How should I get &amp;amp;yrmo automatically replaced by macro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice will be appreciated.&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;Yosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 21:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/21223#M3393</guid>
      <dc:creator>ynchoir</dc:creator>
      <dc:date>2012-03-03T21:58:53Z</dc:date>
    </item>
    <item>
      <title>How to use macro variable in infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/21224#M3394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The file name in your infile statement has to be surrounded by double not single quotes.&amp;nbsp; Otherwise, the macro variable won't resolve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 22:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/21224#M3394</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-03T22:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variable in infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/350102#M81332</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;Does the same work accessing/importing a URL?&amp;nbsp; I want to import a table from a url that has dynamic characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I have below is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var1=2017;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var2='NC'; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var9='Cary'; &lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;filename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; myfile &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;url&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"&lt;A href="http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=" target="_blank"&gt;http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=&lt;/A&gt;&lt;STRONG&gt;&amp;amp;var1&lt;/STRONG&gt;&amp;amp;task=0&amp;amp;state=&lt;STRONG&gt;&amp;amp;var2&lt;/STRONG&gt;&amp;amp;place=&lt;STRONG&gt;&amp;amp;var9&lt;/STRONG&gt;"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;lrecl&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;32767&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;here is the original url.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;filename myfile url "&lt;A href="http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=2017&amp;amp;task=0&amp;amp;state=NC&amp;amp;place=Cary" target="_blank"&gt;http://aa.usno.navy.mil/cgi-bin/aa_rstablew.pl?ID=AA&amp;amp;year=2017&amp;amp;task=0&amp;amp;state=NC&amp;amp;place=Cary&lt;/A&gt;" lrecl=32767;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 17:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/350102#M81332</guid>
      <dc:creator>tobyfarms</dc:creator>
      <dc:date>2017-04-14T17:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variable in infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/350166#M81363</link>
      <description>Single quotes are not needed when assigning values to macro variables unless you want them as part of your string, which in your case I don't think you do. Try:&lt;BR /&gt;%let var2=NC; %let var9=Cary;</description>
      <pubDate>Fri, 14 Apr 2017 19:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-variable-in-infile-statement/m-p/350166#M81363</guid>
      <dc:creator>nehalsanghvi</dc:creator>
      <dc:date>2017-04-14T19:24:35Z</dc:date>
    </item>
  </channel>
</rss>

