<?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 should a SAS program be structured? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361358#M85201</link>
    <description>&lt;P&gt;There are a few ways to look at this, depending on how much code needs to be "modularized" and reused.&amp;nbsp; Here's a good starting point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you re-use a section of SAS code, you often want to do it a little differently each time ... change the data set&amp;nbsp; you are processing, or change some of the variables.&amp;nbsp; As a result, a common tool is to define SAS macros and call the macros as needed.&amp;nbsp; By adding parameters to the macro definitions, you can specify (for example) which data set to process when you call the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros can be stored as separate programs within a folder, and a single line in the program can make all the macros in the folder available if the program requires them.&amp;nbsp; (No cost in terms of CPU time for any macros that are not needed.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It takes some comfort with SAS before you write macros.&amp;nbsp; After all, the macros are generating SAS code and you have to be able to picture what the SAS code should look like.&amp;nbsp; Macros are a separate, more advanced topics.&amp;nbsp; There are books and papers available.&amp;nbsp; That final topic I mentioned, putting macros into a folder, can be searched by looking for "autocall facility".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 May 2017 19:37:09 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-24T19:37:09Z</dc:date>
    <item>
      <title>How should a SAS program be structured?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361319#M85188</link>
      <description>&lt;P&gt;Are there guides for "best practices" on how to structure a SAS program?&amp;nbsp; I'm coming from the python world where I use modules to abstract away parts of my program and import them when needed.&amp;nbsp; Coming to the SAS world I've been using %include statements as an import alternative.&amp;nbsp; I don't think putting all the code on a single program is good practice because it's hard to read.&amp;nbsp; Can any experienced SAS programmers shed some light here?&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 18:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361319#M85188</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2017-05-24T18:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How should a SAS program be structured?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361358#M85201</link>
      <description>&lt;P&gt;There are a few ways to look at this, depending on how much code needs to be "modularized" and reused.&amp;nbsp; Here's a good starting point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you re-use a section of SAS code, you often want to do it a little differently each time ... change the data set&amp;nbsp; you are processing, or change some of the variables.&amp;nbsp; As a result, a common tool is to define SAS macros and call the macros as needed.&amp;nbsp; By adding parameters to the macro definitions, you can specify (for example) which data set to process when you call the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros can be stored as separate programs within a folder, and a single line in the program can make all the macros in the folder available if the program requires them.&amp;nbsp; (No cost in terms of CPU time for any macros that are not needed.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It takes some comfort with SAS before you write macros.&amp;nbsp; After all, the macros are generating SAS code and you have to be able to picture what the SAS code should look like.&amp;nbsp; Macros are a separate, more advanced topics.&amp;nbsp; There are books and papers available.&amp;nbsp; That final topic I mentioned, putting macros into a folder, can be searched by looking for "autocall facility".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 19:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361358#M85201</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-24T19:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: How should a SAS program be structured?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361414#M85227</link>
      <description>&lt;P&gt;I'd second&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;on the &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#p12b2qq72dkxpsn1e19y57emerr6.htm" target="_self"&gt;Autocall &lt;/A&gt;library. &amp;nbsp;I have a decent number of modular functions I've developed over the years that automates frequent tasks like exporting a SAS dataset&amp;nbsp;to a CSV files, moving files/datasets around or creating/adding to log files, etc. and I setup that Autocall library from my autoexec.sas file so all of my code can use those functions. &amp;nbsp;You can also create multiple Autocall libraries, so for larger projects that I want to modularize I create each module as a SAS macro file in a different Autocall library unique to that project, then I can call individual modules as macro functions and can still reference my base library of functions. &amp;nbsp;It's not as formal as what goes on in Python, but it works pretty well for me.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 22:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361414#M85227</guid>
      <dc:creator>Sven111</dc:creator>
      <dc:date>2017-05-24T22:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: How should a SAS program be structured?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361416#M85229</link>
      <description>&lt;P&gt;Just like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/56496"&gt;@Sven111&lt;/a&gt;&amp;nbsp;I also use macros a lot for automating common functions that are frequently repeated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would NOT use macro for is for modularising SAS code. My rule of thumb is if a macro does not contain macro statements to generate SAS code then it is completely unnecessary. It complicates your SAS code for no benefit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do a lot to make your code more readable by laying out nicely using indentation and splitting statements over several lines. If a SAS program is well laid-out, it doesn't matter if it is a few lines or a few hundred lines - it will still be easy to read and understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 22:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-should-a-SAS-program-be-structured/m-p/361416#M85229</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-05-24T22:36:53Z</dc:date>
    </item>
  </channel>
</rss>

