<?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: Basic Program Structure/Flow in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507914#M136356</link>
    <description>&lt;P&gt;Splitting off macros into separate programs is a good idea. A really good way of handling these is by setting up an AUTOCALL macro library. See here for details:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1o5fkxq0gqdpcn1xs3ksdks69tf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1o5fkxq0gqdpcn1xs3ksdks69tf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main advantage of an AUTOCALL library is you don't need to %INCLUDE the programs. SAS does that for you automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've built some pretty large SAS applications and I always use AUTOCALL macro libraries. They help keep your SAS applications structured and tidy as well.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Oct 2018 22:00:05 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2018-10-26T22:00:05Z</dc:date>
    <item>
      <title>Basic Program Structure/Flow</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507898#M136350</link>
      <description>&lt;P&gt;Anybody have some materials / advice on creating a program and how to structure it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I'm working on a program that is currently 600+ lines long and it might end up being 1000 when it is all said and done. It has various data steps, proc sqls, macros, etc. It creates 40+ tables, some temporary, some not. I still learning SAS and haven't really seen anything on structure a long process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've started creating user defined macros in the program to kind of help structure what that series of code is doing. Do people tend to do this? I've been thinking of going back and doing this for other steps that I didn't include in macros. Should I create a program for each one of these macros and then %INCLUDE them in a main program that calls them all and then runs the macros?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice would be great!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 20:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507898#M136350</guid>
      <dc:creator>pchappus</dc:creator>
      <dc:date>2018-10-26T20:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Program Structure/Flow</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507910#M136354</link>
      <description>&lt;P&gt;Are you a BA?&amp;nbsp; Don't break what works.&amp;nbsp; sometimes people write long converted programs to do very long converted process's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507910#M136354</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-10-26T21:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Program Structure/Flow</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507911#M136355</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212034"&gt;@pchappus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Anybody have some materials / advice on creating a program and how to structure it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, I'm working on a program that is currently 600+ lines long and it might end up being 1000 when it is all said and done. It has various data steps, proc sqls, macros, etc. It creates 40+ tables, some temporary, some not. I still learning SAS and haven't really seen anything on structure a long process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've started creating user defined macros in the program to kind of help structure what that series of code is doing. Do people tend to do this? I've been thinking of going back and doing this for other steps that I didn't include in macros. Should I create a program for each one of these macros and then %INCLUDE them in a main program that calls them all and then runs the macros?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice would be great!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First: 1000 lines don't really mean "long program"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if a process is moderately long I tend to divide into functional areas and create separate self-contained program files for each function.&lt;/P&gt;
&lt;P&gt;Typically those would be 1) read the data (if external file is source); 2) clean or verify that the data is useable (no missing values for key variables, variables in defined ranges, all the groups such as organization that should be present are); 3) Restructure data or add variables that are needed for analysis; 4) analysis likely creating data sets for: 5) reporting.&lt;/P&gt;
&lt;P&gt;Pieces that are likely to be needed in multiple parts of the such a library definitions, formats, informats,&amp;nbsp;macros (cautiously) would go into a program file to include at the top of each of those (or make sure it is run before any of them).&lt;/P&gt;
&lt;P&gt;Those may have sub-parts such as reading from external files from multiple sources likely requires a separate read and clean step and likely means that the restructure step means combining data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have to go back to modify a variable or such then rerunning the dependent pieces are relatively easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One strong hint if when you get to the "report" phase, such as would appear between ODS &amp;lt;destination&amp;gt;; Ods &amp;lt;destination&amp;gt; close; statement really shouldn't have any data manipulation. That keeps the output coding much cleaner.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 21:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507911#M136355</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-26T21:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Program Structure/Flow</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507914#M136356</link>
      <description>&lt;P&gt;Splitting off macros into separate programs is a good idea. A really good way of handling these is by setting up an AUTOCALL macro library. See here for details:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1o5fkxq0gqdpcn1xs3ksdks69tf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1o5fkxq0gqdpcn1xs3ksdks69tf.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main advantage of an AUTOCALL library is you don't need to %INCLUDE the programs. SAS does that for you automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've built some pretty large SAS applications and I always use AUTOCALL macro libraries. They help keep your SAS applications structured and tidy as well.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 22:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507914#M136356</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-10-26T22:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Program Structure/Flow</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507939#M136366</link>
      <description>Quick summary:&lt;BR /&gt;&lt;BR /&gt;I break my programs into logical bits. &lt;BR /&gt;&lt;BR /&gt;1. Data import&lt;BR /&gt;2. Data cleaning&lt;BR /&gt;3a. Labels, formats&lt;BR /&gt;3b. Macros needed&lt;BR /&gt;3c. Style templates needed&lt;BR /&gt;4. Analysis&lt;BR /&gt;5. Reporting&lt;BR /&gt;&lt;BR /&gt;I label programs P001 - Program name is long name.sas&lt;BR /&gt;P002 - blah blah &lt;BR /&gt;&lt;BR /&gt;This means programs sort in order. &lt;BR /&gt;&lt;BR /&gt;I also set up several folders:&lt;BR /&gt;&lt;BR /&gt;rawData&lt;BR /&gt;cleanData&lt;BR /&gt;SAS PRograms&lt;BR /&gt;SAS Data sets&lt;BR /&gt;SAS output&lt;BR /&gt;Deliverables&lt;BR /&gt;References&lt;BR /&gt;&lt;BR /&gt;And others as needed. &lt;BR /&gt;&lt;BR /&gt;Other best practices:&lt;BR /&gt;1. Description of program at top of program&lt;BR /&gt;2. Comments -  make them context oriented, why are you doing this? Assume the user can read SAS code, but needs to know why you're doing something. Eg&lt;BR /&gt;Recoding variables to 0/1 from Y/N to allow for quick summarization in proc means. &lt;BR /&gt;&lt;BR /&gt;3. Look for multiple similar steps, 3 data steps back to back can likely be combined. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;That's just a quick starter. If you're looking for more advice, please search on lexjansen.com for best practices guides.</description>
      <pubDate>Sat, 27 Oct 2018 03:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Program-Structure-Flow/m-p/507939#M136366</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-27T03:11:25Z</dc:date>
    </item>
  </channel>
</rss>

