<?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 interpret and implement %include statement in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637298#M8977</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like crspmerge.sas defines a macro, perhaps&amp;nbsp;&lt;A href="https://github.com/jcizel/WRDS-SAS-UTILITIES/blob/master/wrdsmacros/crspmerge.sas" target="_blank"&gt;https://github.com/jcizel/WRDS-SAS-UTILITIES/blob/master/wrdsmacros/crspmerge.sas&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="http://people.stern.nyu.edu/jhasbrou/ftp/sasmacros/crspmerge.sas" target="_blank"&gt;http://people.stern.nyu.edu/jhasbrou/ftp/sasmacros/crspmerge.sas&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are justifiably confused because the comments in the code are wrong:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include '/wrds/crsp/samples/crspmerge.sas'; /* second dataset*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The purpose of the %INCLUDE statement is to execute the code in the program crspmerge.sas.&amp;nbsp; That code does not create a second dataset.&amp;nbsp; It compiles a macro named crspmerge.&amp;nbsp; After the macro has been compiled, you can call the macro, and the macro will write some output datasets.&amp;nbsp; The macro has a number of dependencies that are not clearly defined, for example it expects certain data tables to exist in the directory&amp;nbsp;&lt;SPAN class="pl-k"&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;wrds&lt;/SPAN&gt;&lt;SPAN class="pl-k"&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;crsp&lt;/SPAN&gt;&lt;SPAN class="pl-k"&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;sasdata&lt;/SPAN&gt;&lt;SPAN class="pl-k"&gt;/.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;You should not need to create macro variables in order to use the macro.&amp;nbsp; In order to use the macro, you need to compile the macro (which means you must run the code in crspmerge.sas).&amp;nbsp; One way to run that code is to use %INCLUDE.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;So you should be able to run the macro like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include '/wrds/crsp/samples/crspmerge.sas';  /*Execute crspmerge.sas to compile the macro CRSPmerge*/

/*now call the macro*/
%crspmerge(s=m,start=01jan1959,end=30jun2011, sfvars=prc ret retx shrout cfacpr cfacshr,sevars=ticker ncusip shrcd exchcd,filters=exchcd in (1,2,3));

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;I hope that helps.&amp;nbsp; Getting started with macros is hard.&amp;nbsp; And if your first time trying to use a macro is to run a complicated macro like this, written by someone else, and not well-documented, that makes it harder.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;One suggestion is to turn on options MPRINT and SYMBOLGEN and MLOGIC before you call the macro.&amp;nbsp; That will write helpful debugging info to your log.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;Good Luck.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Apr 2020 16:01:31 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2020-04-03T16:01:31Z</dc:date>
    <item>
      <title>How to interpret and implement %include statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637294#M8974</link>
      <description>&lt;P&gt;I have the following code which takes variables from two datasets and then uses it to form a new table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token macro-keyword keyword"&gt;%let&lt;/SPAN&gt;&lt;SPAN&gt; msevars&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;ticker ncusip shrcd exchcd&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token macro-keyword keyword"&gt;%let&lt;/SPAN&gt;&lt;SPAN&gt; msfvars &lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; prc ret retx shrout cfacpr cfacshr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;; /* variables from the first dataset */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token macro-keyword keyword"&gt;%include&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'/wrds/crsp/samples/crspmerge.sas'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;; /* second dataset*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token function keyword"&gt;%crspmerge&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;s&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;m&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;start&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;01jan1959&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;end&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;30jun2011&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt; sfvars&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt;msfvars&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;sevars&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt;msevars&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;filters&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;exchcd &lt;/SPAN&gt;&lt;SPAN class="token operator-keyword operator"&gt;in&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying to replicate&amp;nbsp; the %include statement&amp;nbsp; for the crspmerge dataset that I have saved in my myfolders like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;%include '/folders/myfolders/comp/merged.sas7bdat';&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I get this error "&lt;SPAN&gt;Maximum level of nesting of macro functions exceeded".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Am I using the statement wrong, if not, is there a different way to do this procedure without using macro variables . I am a noobie in sas so be patient with me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 15:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637294#M8974</guid>
      <dc:creator>avecesar97</dc:creator>
      <dc:date>2020-04-03T15:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to interpret and implement %include statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637295#M8975</link>
      <description>&lt;P&gt;A %INCLUDE statement is for included lines of CODE.&amp;nbsp; Not a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having an include followed by a macro call to a macro with same name as the file that was included makes it look like that file just has the MACRO definition. I would be surprised if that file had any code that defined any datasets.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 15:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637295#M8975</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-03T15:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to interpret and implement %include statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637296#M8976</link>
      <description>&lt;P&gt;Do you mean that you are attempting to USE the data set? Or something else, if so what?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 15:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637296#M8976</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-03T15:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to interpret and implement %include statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637298#M8977</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like crspmerge.sas defines a macro, perhaps&amp;nbsp;&lt;A href="https://github.com/jcizel/WRDS-SAS-UTILITIES/blob/master/wrdsmacros/crspmerge.sas" target="_blank"&gt;https://github.com/jcizel/WRDS-SAS-UTILITIES/blob/master/wrdsmacros/crspmerge.sas&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="http://people.stern.nyu.edu/jhasbrou/ftp/sasmacros/crspmerge.sas" target="_blank"&gt;http://people.stern.nyu.edu/jhasbrou/ftp/sasmacros/crspmerge.sas&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are justifiably confused because the comments in the code are wrong:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include '/wrds/crsp/samples/crspmerge.sas'; /* second dataset*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The purpose of the %INCLUDE statement is to execute the code in the program crspmerge.sas.&amp;nbsp; That code does not create a second dataset.&amp;nbsp; It compiles a macro named crspmerge.&amp;nbsp; After the macro has been compiled, you can call the macro, and the macro will write some output datasets.&amp;nbsp; The macro has a number of dependencies that are not clearly defined, for example it expects certain data tables to exist in the directory&amp;nbsp;&lt;SPAN class="pl-k"&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;wrds&lt;/SPAN&gt;&lt;SPAN class="pl-k"&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;crsp&lt;/SPAN&gt;&lt;SPAN class="pl-k"&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;sasdata&lt;/SPAN&gt;&lt;SPAN class="pl-k"&gt;/.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;You should not need to create macro variables in order to use the macro.&amp;nbsp; In order to use the macro, you need to compile the macro (which means you must run the code in crspmerge.sas).&amp;nbsp; One way to run that code is to use %INCLUDE.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;So you should be able to run the macro like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include '/wrds/crsp/samples/crspmerge.sas';  /*Execute crspmerge.sas to compile the macro CRSPmerge*/

/*now call the macro*/
%crspmerge(s=m,start=01jan1959,end=30jun2011, sfvars=prc ret retx shrout cfacpr cfacshr,sevars=ticker ncusip shrcd exchcd,filters=exchcd in (1,2,3));

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;I hope that helps.&amp;nbsp; Getting started with macros is hard.&amp;nbsp; And if your first time trying to use a macro is to run a complicated macro like this, written by someone else, and not well-documented, that makes it harder.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;One suggestion is to turn on options MPRINT and SYMBOLGEN and MLOGIC before you call the macro.&amp;nbsp; That will write helpful debugging info to your log.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="pl-k"&gt;Good Luck.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 16:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-interpret-and-implement-include-statement/m-p/637298#M8977</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-04-03T16:01:31Z</dc:date>
    </item>
  </channel>
</rss>

