<?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 call my macro created? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725831#M225524</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/373637"&gt;@xtan2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello. Paige,&lt;/P&gt;
&lt;P&gt;Thank you for your reply.&lt;BR /&gt;Actually, both this folder path&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;C:\Users\thisi\Documents\&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;and the catalog sasmacr exist.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;"catalog sasmacr exist" — but that's not what I said. And that's not what you told SAS to look for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is looking for a file named slreg.sas in that folder. Why? Because that's what you said to look for in the %include statement. And it's not in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can access your macro without %include. Just use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%slreg(newyear2010, dep=sale, indep=day)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;without any %include (you may have to restart SAS, because it is now looking for the %slreg macro elsewhere, perhaps there is a way to eliminate this problem without restarting SAS, but I am not aware of the method).&lt;/P&gt;</description>
    <pubDate>Fri, 12 Mar 2021 16:43:58 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-03-12T16:43:58Z</dc:date>
    <item>
      <title>How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725824#M225521</link>
      <description>&lt;P&gt;Hello. Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;My code to import the file is&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Proc Import Datafile = 'D:\STAT_8020_Advanced_SAS\HW4\new.year2010.csv'&lt;DIV&gt;DBMS = csv&lt;/DIV&gt;&lt;DIV&gt;Out = sasuser.newyear2010&lt;/DIV&gt;&lt;DIV&gt;Replace;&lt;/DIV&gt;&lt;DIV&gt;Run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Data newyear2010;&lt;/DIV&gt;&lt;DIV&gt;Set sasuser.newyear2010;&lt;/DIV&gt;Run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;I have successfully created and stored the following macro for creating a linear regression:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;libname Doc 'C:\Users\thisi\Documents';&lt;BR /&gt;Options mstored sasmstore = Doc;&lt;BR /&gt;%macro slreg(dataset, dep=, indep=)/store source;&lt;BR /&gt;Proc Reg Data= &amp;amp;dataset;&lt;BR /&gt;Model &amp;amp;dep = &amp;amp;indep;&lt;BR /&gt;Run;&lt;BR /&gt;%mend;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It could be easily called using&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%slreg(newyear2010, dep=sale, indep=day)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;However, when I tried to call it using the %include procedure in this following code:&lt;/DIV&gt;&lt;DIV&gt;%include 'C:\Users\thisi\Documents\slreg.sas' /source2;&lt;/DIV&gt;&lt;DIV&gt;it was not successful.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The SAS log error message is&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;115 %include 'C:\Users\thisi\Documents\slreg.sas' /source2;&lt;BR /&gt;WARNING: Physical file does not exist, C:\Users\thisi\Documents\slreg.sas.&lt;BR /&gt;ERROR: Cannot open %INCLUDE file C:\Users\thisi\Documents\slreg.sas.&lt;BR /&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;When I tried to call it using the Proc Catalog procedure in this following code, it was also unsuccessful:&lt;/DIV&gt;&lt;DIV&gt;Filename slreg Catalog 'Doc.Sasmacr';&lt;BR /&gt;%include slreg / source2;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The SAS log is&lt;/DIV&gt;&lt;DIV&gt;117 Filename slreg Catalog 'Doc.Sasmacr';&lt;BR /&gt;118 %include slreg / source2;&lt;BR /&gt;ERROR: For sequential access, physical name must be at least 3 levels.&lt;BR /&gt;ERROR: Cannot open %INCLUDE file SLREG.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Would you like to give me some hint about the possible solution?&lt;/DIV&gt;&lt;DIV&gt;Thank you very much!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 Mar 2021 16:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725824#M225521</guid>
      <dc:creator>xtan2</dc:creator>
      <dc:date>2021-03-12T16:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725825#M225522</link>
      <description>&lt;PRE&gt;115 %include 'C:\Users\thisi\Documents\slreg.sas' /source2;
WARNING: Physical file does not exist, C:\Users\thisi\Documents\slreg.sas.
ERROR: Cannot open %INCLUDE file C:\Users\thisi\Documents\slreg.sas.&lt;/PRE&gt;
&lt;P&gt;You cannot refer to a folder/file that does not exist. You have to refer to a folder/file that does exist. If you look in Windows Explorer, you will see that no file named slreg.sas exists in the folder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your macro is not stored as a SAS file. It is stored in a SAS catalog named DOC. I believe you should just call the macro, without %include.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 16:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725825#M225522</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-12T16:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725828#M225523</link>
      <description>&lt;P&gt;Hello. Paige,&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;BR /&gt;Actually, both this folder path&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;C:\Users\thisi\Documents\&lt;/PRE&gt;&lt;P&gt;and the catalog sasmacr exist.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xtan2_0-1615567024543.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55883iBCC6DC834CB21E8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xtan2_0-1615567024543.png" alt="xtan2_0-1615567024543.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is why the error seems confusing.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 16:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725828#M225523</guid>
      <dc:creator>xtan2</dc:creator>
      <dc:date>2021-03-12T16:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725831#M225524</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/373637"&gt;@xtan2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello. Paige,&lt;/P&gt;
&lt;P&gt;Thank you for your reply.&lt;BR /&gt;Actually, both this folder path&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;C:\Users\thisi\Documents\&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;and the catalog sasmacr exist.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;"catalog sasmacr exist" — but that's not what I said. And that's not what you told SAS to look for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is looking for a file named slreg.sas in that folder. Why? Because that's what you said to look for in the %include statement. And it's not in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can access your macro without %include. Just use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%slreg(newyear2010, dep=sale, indep=day)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;without any %include (you may have to restart SAS, because it is now looking for the %slreg macro elsewhere, perhaps there is a way to eliminate this problem without restarting SAS, but I am not aware of the method).&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 16:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725831#M225524</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-12T16:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725837#M225527</link>
      <description>&lt;P&gt;Yes. I have successfully use this code:&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;%slreg(newyear2010, dep=sale, indep=day)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It works well.&lt;/P&gt;&lt;P&gt;But we were asked to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;In the year2010 data, consider sale as your response variables, day as your independent variable. Write a sas macro for simple linear regression by considering (sale and day as the dependent and independent variable) and store it. Call this regression by following approaches&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;%include&lt;/LI&gt;&lt;LI&gt;Catalog access method&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;When I tried to call the saved macro of slreg, none of the strategies have worked. So I posted my question here.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 17:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725837#M225527</guid>
      <dc:creator>xtan2</dc:creator>
      <dc:date>2021-03-12T17:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725838#M225528</link>
      <description>&lt;P&gt;To get %include to work, you specifically have to save the macro in a file named slreg.sas in that folder. It doesn't work if there isn't a file named slreg.sas in that folder.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 17:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725838#M225528</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-12T17:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725841#M225529</link>
      <description>&lt;P&gt;This is the confusing point: I have already created the macro slreg and it exists:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xtan2_0-1615569146057.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55884iA4A7E827F2734262/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xtan2_0-1615569146057.png" alt="xtan2_0-1615569146057.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do I have to change the type of this macro from Macro into SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 17:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725841#M225529</guid>
      <dc:creator>xtan2</dc:creator>
      <dc:date>2021-03-12T17:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725856#M225535</link>
      <description>&lt;P&gt;You want a file type of .sas&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Changing the file type of the file you just showed will not work.&amp;nbsp;You have to save the macro as text, with file name slreg.sas&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 18:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725856#M225535</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-12T18:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to call my macro created?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725859#M225538</link>
      <description>&lt;P&gt;Is the image of the "sasmacr" that makes you think your file is there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's a catalog file, not a .sas file. I would recommend changing your Windows viewer settings so you can see the extensions on the file or add the file type in the viewer. Then you'll see the file type is not a SAS program file, it's a SAS catalog with an extension of sas7bcat. So your %include is looking for a file with the extension ".sas". It will be the program file from your first post,&amp;nbsp; saved to the location below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the %INCLUDE doesn't work because there is no .sas file there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how that solution would work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include 'path to .sas file with macro code';

%slreg(newyear2010, dep=sale, indep=day);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/373637"&gt;@xtan2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello. Paige,&lt;/P&gt;
&lt;P&gt;Thank you for your reply.&lt;BR /&gt;Actually, both this folder path&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;C:\Users\thisi\Documents\&lt;/PRE&gt;
&lt;P&gt;and the catalog sasmacr exist.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xtan2_0-1615567024543.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55883iBCC6DC834CB21E8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xtan2_0-1615567024543.png" alt="xtan2_0-1615567024543.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is why the error seems confusing.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 18:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-call-my-macro-created/m-p/725859#M225538</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-12T18:02:41Z</dc:date>
    </item>
  </channel>
</rss>

