<?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 Open a file in a Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Open-a-file-in-a-Macro/m-p/191224#M36077</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am a newbie in SAS programming. I was wondering if it is possible to open a SAS file in a macro and use its variables to do some calculations? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to be more specific, I am trying to write a macro for changing currencies to AUD but not the current rates to get it from a live data source rather I need historical rates. So I have the historical exchange rates downloaded from Reserve bank of Australia and already imported to SAS. But have not yet figured out how to write a macro to open the file and use its values. Something that I have tried is the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro convert_currency(x,CUR,Date);&lt;/P&gt;&lt;P&gt;%let fopen(exchange_rates,I);&lt;/P&gt;&lt;P&gt;%IF exchange_rates.date=&amp;amp;date %then Rate=&amp;amp;CUR;&lt;/P&gt;&lt;P&gt;%let &amp;amp;x._convert=&amp;amp;x*rate;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend convert_currency;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will be thankful if someone can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Oct 2014 17:45:57 GMT</pubDate>
    <dc:creator>Nargess</dc:creator>
    <dc:date>2014-10-20T17:45:57Z</dc:date>
    <item>
      <title>Open a file in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Open-a-file-in-a-Macro/m-p/191224#M36077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am a newbie in SAS programming. I was wondering if it is possible to open a SAS file in a macro and use its variables to do some calculations? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to be more specific, I am trying to write a macro for changing currencies to AUD but not the current rates to get it from a live data source rather I need historical rates. So I have the historical exchange rates downloaded from Reserve bank of Australia and already imported to SAS. But have not yet figured out how to write a macro to open the file and use its values. Something that I have tried is the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro convert_currency(x,CUR,Date);&lt;/P&gt;&lt;P&gt;%let fopen(exchange_rates,I);&lt;/P&gt;&lt;P&gt;%IF exchange_rates.date=&amp;amp;date %then Rate=&amp;amp;CUR;&lt;/P&gt;&lt;P&gt;%let &amp;amp;x._convert=&amp;amp;x*rate;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend convert_currency;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will be thankful if someone can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Oct 2014 17:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Open-a-file-in-a-Macro/m-p/191224#M36077</guid>
      <dc:creator>Nargess</dc:creator>
      <dc:date>2014-10-20T17:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Open a file in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Open-a-file-in-a-Macro/m-p/191225#M36078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If by SAS file you mean a SAS dataset then I suggest you use a SAS DATA step for that. BTW the FOPEN function is for external files, usually text, and not SAS datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To start with just build a simple DATA step without using a macro, then once that is working, convert it to a macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set old;&lt;/P&gt;&lt;P&gt;&amp;nbsp; currency_aud = currency * rate;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Oct 2014 18:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Open-a-file-in-a-Macro/m-p/191225#M36078</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2014-10-20T18:46:02Z</dc:date>
    </item>
  </channel>
</rss>

