<?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: Generate template SAS code with comments in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101916#M28605</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One useful trick is to use the RESOLVE function.&lt;/P&gt;&lt;P&gt;Build a text file with the template and put macro variable references (or even macro calls as long as the macro just generate text).&lt;/P&gt;&lt;P&gt;Then use a data step to read the template, resolve the macro variable references and write the new program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;template.sas&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;/%str(*)-----------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Program: &amp;amp;program&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Project: &amp;amp;project&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Title: &amp;amp;title&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Author: &amp;amp;author&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Initial Date: &amp;amp;sysdate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;------------------------------------------------------------------------------%str(*)/&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let project=XYZ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let program=main.sas ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let title = Main SAS program for Project &amp;amp;project;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let author=A. Programmer ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile 'template.sas' lrecl=300 truncover;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; file "&amp;amp;program" lrecl=300;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input line $char300.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; line = resolve(trim(line));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; len = length(line);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put line $varying300. len ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main.sas&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;/*-----------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Program: main.sas&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Project: XYZ&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Title: Main SAS program for Project XYZ&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Author: A. Programmer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Initial Date: 17DEC12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;------------------------------------------------------------------------------*/&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Dec 2012 00:10:59 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-12-19T00:10:59Z</dc:date>
    <item>
      <title>Generate template SAS code with comments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101912#M28601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been writing several SAS programs recently using similar formatting (e.g my name/project name in comment at the beginning, filename variables etc). I was wondering if there is a neat way to write a "SAS template generator" program/macro that could take a username\project name\date\whatever else, and generate a new SAS program file that includes a standard header in comments with this information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be convenient to only have to enter it once, because this information appears several times in each program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any light on this!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 15:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101912#M28601</guid>
      <dc:creator>hypermonkey2</dc:creator>
      <dc:date>2012-12-17T15:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Generate template SAS code with comments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101913#M28602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Making a macro is a good choice .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 01:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101913#M28602</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-12-18T01:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Generate template SAS code with comments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101914#M28603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to mention that I am familiar with macros, I was looking for the best way using that. I think that using the FILE command along with a series of PUT statements could work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 16:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101914#M28603</guid>
      <dc:creator>hypermonkey2</dc:creator>
      <dc:date>2012-12-18T16:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Generate template SAS code with comments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101915#M28604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it depends on how good your meta data is.&amp;nbsp; If you have useful info that can drive the report then a data step can easily write report. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT="SAS program template"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 16:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101915#M28604</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-12-18T16:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Generate template SAS code with comments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101916#M28605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One useful trick is to use the RESOLVE function.&lt;/P&gt;&lt;P&gt;Build a text file with the template and put macro variable references (or even macro calls as long as the macro just generate text).&lt;/P&gt;&lt;P&gt;Then use a data step to read the template, resolve the macro variable references and write the new program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;template.sas&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;/%str(*)-----------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Program: &amp;amp;program&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Project: &amp;amp;project&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Title: &amp;amp;title&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Author: &amp;amp;author&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Initial Date: &amp;amp;sysdate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;------------------------------------------------------------------------------%str(*)/&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let project=XYZ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let program=main.sas ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let title = Main SAS program for Project &amp;amp;project;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let author=A. Programmer ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile 'template.sas' lrecl=300 truncover;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; file "&amp;amp;program" lrecl=300;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input line $char300.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; line = resolve(trim(line));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; len = length(line);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put line $varying300. len ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main.sas&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;/*-----------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Program: main.sas&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Project: XYZ&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Title: Main SAS program for Project XYZ&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Author: A. Programmer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Initial Date: 17DEC12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;------------------------------------------------------------------------------*/&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2012 00:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101916#M28605</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-12-19T00:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generate template SAS code with comments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101917#M28606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very useful! Was not aware of Resolve. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 16:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-template-SAS-code-with-comments/m-p/101917#M28606</guid>
      <dc:creator>hypermonkey2</dc:creator>
      <dc:date>2012-12-20T16:43:22Z</dc:date>
    </item>
  </channel>
</rss>

