<?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 macros to apply macros from text file on csv dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457785#M116115</link>
    <description>&lt;P&gt;Can you share your macro definitions?&lt;/P&gt;
&lt;P&gt;I would try with a .sas file that you know is correct to see if it's a path issue or a file issue.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Apr 2018 15:14:01 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-04-26T15:14:01Z</dc:date>
    <item>
      <title>How to use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457644#M116044</link>
      <description>&lt;DIV class="votecell post-layout--left"&gt;&lt;DIV class="vote"&gt;&lt;DIV class="favoritecount"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="postcell post-layout--right"&gt;&lt;DIV class="post-text"&gt;&lt;P&gt;I have a text file "Macro definition" which has two SAS macros definition. I would like to import them and apply on HTWT.csv data set. This dataset has 20 observations and 6 variables ID, Gender, Age,Height,Weight,Year. All are numeric except gender variable. I have the code below to import and apply the macros from the txt file to csv file. I am getting an error message on running this code as below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%macro import_myfile(i=);
proc import file="C:\Users\komal\Desktop\Advanced SAS\Macro definition.txt" out=Macrodefinition dlm='09x' replace;
run;
%mend import_myfile;
%include Macrodefinition;

Error: Unable to complete processing of INCLUDE. Expected a filename or fileref
Failed to open macro : The system cannot find the file specified&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;Please let me know your advice on how to solve it. Thank you for your time.&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 26 Apr 2018 13:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457644#M116044</guid>
      <dc:creator>Komal2</dc:creator>
      <dc:date>2018-04-26T13:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457648#M116046</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/199745"&gt;@Komal2&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;DIV class="votecell post-layout--left"&gt;
&lt;DIV class="vote"&gt;
&lt;DIV class="favoritecount"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="postcell post-layout--right"&gt;
&lt;DIV class="post-text"&gt;
&lt;P&gt;I have a text file "Macro definition" which has two SAS macros definition. I would like to import them and apply on HTWT.csv data set. This dataset has 20 observations and 6 variables ID, Gender, Age,Height,Weight,Year. All are numeric except gender variable. I have the code below to import and apply the macros from the txt file to csv file. I am getting an error message on running this code as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%macro import_myfile(i=);
proc import file="C:\Users\komal\Desktop\Advanced SAS\Macro definition.txt" out=Macrodefinition dlm='09x' replace;
run;
%mend import_myfile;
%include Macrodefinition;

Error: Unable to complete processing of INCLUDE. Expected a filename or fileref
Failed to open macro : The system cannot find the file specified&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
Please let me know your advice on how to solve it. Thank you for your time.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your macro definition for import_myfile is completely unnecessary. There's no dynamic code at all, parameter &amp;amp;i is never used. Stop making things unnecessarily complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a %include statement needs either a physical filename, or a file reference created by a filename statement.&lt;/P&gt;
&lt;P&gt;Either add a statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename Macrodefinition "physical filename comes here";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or use the physical filename in quotes in the %include.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 09:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457648#M116046</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-26T09:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457665#M116054</link>
      <description>&lt;P&gt;Text files don't need to be imported.&amp;nbsp; They just need to exist.&amp;nbsp; You might use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%include "C:\Users\komal\Desktop\Advanced SAS\Macro definition.txt";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then any macros defined within that text file will be available.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 10:22:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457665#M116054</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-26T10:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457668#M116056</link>
      <description>Thanks. How can I apply the 2 macros from the Txt file to HTWT. csv&lt;BR /&gt;dataset?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Apr 2018 10:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457668#M116056</guid>
      <dc:creator>Komal2</dc:creator>
      <dc:date>2018-04-26T10:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457670#M116058</link>
      <description>&lt;P&gt;That's something you need to learn.&amp;nbsp; There are multiple ways, depending on how the macros are defined.&amp;nbsp; You will need to roll up your sleeves, find some documentation and study it.&amp;nbsp; This might be a decent starting point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0pfmkjlc3e719n1lks4go8ke61r.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0pfmkjlc3e719n1lks4go8ke61r.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 10:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457670#M116058</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-26T10:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457671#M116059</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;%include "C:\Users\komal\Desktop\Advanced SAS\Macro definition.txt";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have tried to use the code above to call the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting an error message below. I have checked the location of the file and it is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

Unable to compllete processing of INCLUDE. Expected a filename or fileref.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something I am missing here?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 10:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457671#M116059</guid>
      <dc:creator>Komal2</dc:creator>
      <dc:date>2018-04-26T10:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457672#M116060</link>
      <description>&lt;P&gt;Just to set the record straight, this statement will not call the macro.&amp;nbsp; It will make the macro available within your program, so that later statements within the program can call the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's see the log that contains the error.&amp;nbsp; That's the usual source of debugging information.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 10:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457672#M116060</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-26T10:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457673#M116061</link>
      <description>&lt;P&gt;Please use copy and paste for logs, don't type them off the screen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Unable to compllete processing of INCLUDE&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;Ex&lt;/SPAN&gt;pected a &lt;SPAN class="token statement"&gt;filename&lt;/SPAN&gt; or &lt;SPAN class="token function"&gt;fileref&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;SAS logs are correctly spelled, so it would be "complete" instead of "compllete".&lt;/P&gt;
&lt;P&gt;Copy/paste the whole log resulting from your include into a {i} window, no changes, no additions, no omissions.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 10:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457673#M116061</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-26T10:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457682#M116063</link>
      <description>&lt;P&gt;I am working on SAS in remote desktop. I am unable to copy/paste from SAS in remote desktop.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 11:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457682#M116063</guid>
      <dc:creator>Komal2</dc:creator>
      <dc:date>2018-04-26T11:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457694#M116066</link>
      <description>&lt;P&gt;I tried the code below to call the macro.&lt;/P&gt;&lt;P&gt;outcsvv is the name of HTWT dataset imported in SAS.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%include "C:\Users\komal\Desktop\Advanced SAS\Macro definition.txt";
%contents_of(outcsvv)
%print_data(outcsvv)

Error: Unable to complete processing of INCLUDE. Expected a filename or fileref
Expected a statement keyword: found "("&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The second error I am getting is probably due to the macro definition(s) from the text file which are as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%macro contents_of(name);
proc contents data=&amp;amp;name;
run;
%mend;


%macro print_data(name);
proc print data=&amp;amp;name;
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please let me know your advice on how to solve it. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 12:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457694#M116066</guid>
      <dc:creator>Komal2</dc:creator>
      <dc:date>2018-04-26T12:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457726#M116081</link>
      <description>&lt;P&gt;There are communication issues that I don't understand when you are working from a remote desktop.&amp;nbsp; How do you refer to a file from the desktop, when the file is stored elsewhere?&amp;nbsp; For a single-machine environment, it looks like you are taking all the right steps (including calling the macros).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Certainly for these two macros you don't need macros.&amp;nbsp; It's easy enough to code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=outcsvv;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=outcsvv;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So can I assume that these are smaller versions of what the macros actually contain?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 13:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457726#M116081</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-26T13:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457728#M116083</link>
      <description>&lt;P&gt;I would not be surprised at all if there's some translation issue of keystrokes between the remote and local desktop, as SAS seems to misinterpret the whole filename string (including the quotes)&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 13:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457728#M116083</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-26T13:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to apply macros from text file on csv dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457785#M116115</link>
      <description>&lt;P&gt;Can you share your macro definitions?&lt;/P&gt;
&lt;P&gt;I would try with a .sas file that you know is correct to see if it's a path issue or a file issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 15:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-apply-macros-from-text-file-on-csv-dataset/m-p/457785#M116115</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-26T15:14:01Z</dc:date>
    </item>
  </channel>
</rss>

