<?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 Write macro using data _null_ and put statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24885#M4255</link>
    <description>I am using SAS9.2 on windows, when I submit the following statements:&lt;BR /&gt;
*****************************************************;&lt;BR /&gt;
%let mymacro=%str(C:\mymacro.sas);&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 file mymacro;&lt;BR /&gt;
 put "%macro mymacro(crt=);" ;&lt;BR /&gt;
 put "More code";&lt;BR /&gt;
 &lt;BR /&gt;
 put "%mend mymacro();" ;&lt;BR /&gt;
run;&lt;BR /&gt;
****************;&lt;BR /&gt;
&lt;BR /&gt;
I got this note in the log and the data step doesn't finish:&lt;BR /&gt;
***Log ***;&lt;BR /&gt;
101  data _null_;&lt;BR /&gt;
102   file mymacro;&lt;BR /&gt;
103   put "%macro mymacro(crt=);"&lt;BR /&gt;
                                ---------&lt;BR /&gt;
                                49&lt;BR /&gt;
103!  ;&lt;BR /&gt;
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.  Inserting white space&lt;BR /&gt;
             between a quoted string and the succeeding identifier is recommended.&lt;BR /&gt;
&lt;BR /&gt;
104   put "More code";&lt;BR /&gt;
105&lt;BR /&gt;
106   put "%mend mymacro();" ;&lt;BR /&gt;
107  run;&lt;BR /&gt;
**********end of log*********;&lt;BR /&gt;
&lt;BR /&gt;
If I submit the following code:&lt;BR /&gt;
***************************;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 file mymacro;&lt;BR /&gt;
 put "%%macro mymacro(crt=);" ;&lt;BR /&gt;
 put "More code";&lt;BR /&gt;
 &lt;BR /&gt;
 put "%%mend mymacro();" ;&lt;BR /&gt;
run;&lt;BR /&gt;
***********;&lt;BR /&gt;
&lt;BR /&gt;
I got the following output, noticing the double %. How do I make SAS to output only one %?&lt;BR /&gt;
&lt;BR /&gt;
*******************;&lt;BR /&gt;
%%macro mymacro(crt=);&lt;BR /&gt;
More code&lt;BR /&gt;
%%mend mymacro();&lt;BR /&gt;
*****************************;</description>
    <pubDate>Thu, 28 Oct 2010 19:41:34 GMT</pubDate>
    <dc:creator>fd2010</dc:creator>
    <dc:date>2010-10-28T19:41:34Z</dc:date>
    <item>
      <title>Write macro using data _null_ and put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24885#M4255</link>
      <description>I am using SAS9.2 on windows, when I submit the following statements:&lt;BR /&gt;
*****************************************************;&lt;BR /&gt;
%let mymacro=%str(C:\mymacro.sas);&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 file mymacro;&lt;BR /&gt;
 put "%macro mymacro(crt=);" ;&lt;BR /&gt;
 put "More code";&lt;BR /&gt;
 &lt;BR /&gt;
 put "%mend mymacro();" ;&lt;BR /&gt;
run;&lt;BR /&gt;
****************;&lt;BR /&gt;
&lt;BR /&gt;
I got this note in the log and the data step doesn't finish:&lt;BR /&gt;
***Log ***;&lt;BR /&gt;
101  data _null_;&lt;BR /&gt;
102   file mymacro;&lt;BR /&gt;
103   put "%macro mymacro(crt=);"&lt;BR /&gt;
                                ---------&lt;BR /&gt;
                                49&lt;BR /&gt;
103!  ;&lt;BR /&gt;
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.  Inserting white space&lt;BR /&gt;
             between a quoted string and the succeeding identifier is recommended.&lt;BR /&gt;
&lt;BR /&gt;
104   put "More code";&lt;BR /&gt;
105&lt;BR /&gt;
106   put "%mend mymacro();" ;&lt;BR /&gt;
107  run;&lt;BR /&gt;
**********end of log*********;&lt;BR /&gt;
&lt;BR /&gt;
If I submit the following code:&lt;BR /&gt;
***************************;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 file mymacro;&lt;BR /&gt;
 put "%%macro mymacro(crt=);" ;&lt;BR /&gt;
 put "More code";&lt;BR /&gt;
 &lt;BR /&gt;
 put "%%mend mymacro();" ;&lt;BR /&gt;
run;&lt;BR /&gt;
***********;&lt;BR /&gt;
&lt;BR /&gt;
I got the following output, noticing the double %. How do I make SAS to output only one %?&lt;BR /&gt;
&lt;BR /&gt;
*******************;&lt;BR /&gt;
%%macro mymacro(crt=);&lt;BR /&gt;
More code&lt;BR /&gt;
%%mend mymacro();&lt;BR /&gt;
*****************************;</description>
      <pubDate>Thu, 28 Oct 2010 19:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24885#M4255</guid>
      <dc:creator>fd2010</dc:creator>
      <dc:date>2010-10-28T19:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Write macro using data _null_ and put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24886#M4256</link>
      <description>Suggest you share the first 100 lines of your SAS log as well.....&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 28 Oct 2010 20:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24886#M4256</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-28T20:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Write macro using data _null_ and put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24887#M4257</link>
      <description>That is all there is. I also got the 'Data Step running' in the Editor window bar, i.e., it hangs there until I quit SAS. Then it is saying %mend missing in the log before exiting. Essentially, I wonder how I can write a macro with put statement?&lt;BR /&gt;
&lt;BR /&gt;
*************************************************************;&lt;BR /&gt;
1    %let mymacro=%str(C:\mymacro.sas);&lt;BR /&gt;
2    data _null_;&lt;BR /&gt;
3    file mymacro;&lt;BR /&gt;
4    put "%macro mymacro(crt=);"&lt;BR /&gt;
                               --------&lt;BR /&gt;
                               49&lt;BR /&gt;
4  !  ;&lt;BR /&gt;
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release.  Inserting white space&lt;BR /&gt;
             between a quoted string and the succeeding identifier is recommended.&lt;BR /&gt;
&lt;BR /&gt;
5    put "More code";&lt;BR /&gt;
6&lt;BR /&gt;
7    put "%mend mymacro();" ;&lt;BR /&gt;
8    run;</description>
      <pubDate>Thu, 28 Oct 2010 20:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24887#M4257</guid>
      <dc:creator>fd2010</dc:creator>
      <dc:date>2010-10-28T20:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Write macro using data _null_ and put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24888#M4258</link>
      <description>It dawned on me that if I used single quote, I don't get the note in the log and the output is fine with one %!&lt;BR /&gt;
&lt;BR /&gt;
Thanks to everyone who tried to help!&lt;BR /&gt;
&lt;BR /&gt;
*****************************************************;&lt;BR /&gt;
%let mymacro=%str(C:\mymacro.sas);&lt;BR /&gt;
data _null_;&lt;BR /&gt;
file mymacro;&lt;BR /&gt;
put '%macro mymacro(crt=);' ;&lt;BR /&gt;
put "More code";&lt;BR /&gt;
&lt;BR /&gt;
put '%mend mymacro();' ;&lt;BR /&gt;
run;&lt;BR /&gt;
****************;</description>
      <pubDate>Thu, 28 Oct 2010 20:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-macro-using-data-null-and-put-statement/m-p/24888#M4258</guid>
      <dc:creator>fd2010</dc:creator>
      <dc:date>2010-10-28T20:42:01Z</dc:date>
    </item>
  </channel>
</rss>

