<?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: Is this code structure available for SAS? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111038#M30791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what the advantage would be.&amp;nbsp; But to be able to do it exactly that way SAS would need to be a compiled language instead of an interpreted one.&amp;nbsp; You could structure your source that way in SCL since it needs to be compiled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really wanted to create code in that form you could wrap the main routine in a macro and then call it at the bottom of the file after all the sub macros have been defined.&amp;nbsp; But I do not recommend it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro main;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %sub1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %sub2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;%mend main;&lt;/P&gt;&lt;P&gt;%macro sub1;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;%mend sub1;&lt;/P&gt;&lt;P&gt;%macro sub2;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;%mend sub2;&lt;/P&gt;&lt;P&gt;%main;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A more natural process would be to create autocall library for the subroutine macros. Create a separate file with each macro's definition and store them in a directory.&amp;nbsp; Then you main program could look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options sasautos=('mymacros');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sub1;&lt;/P&gt;&lt;P&gt;%sub2;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Jul 2012 22:59:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-07-18T22:59:02Z</dc:date>
    <item>
      <title>Is this code structure available for SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111035#M30788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want create a SAS code with this structure: I am not sure whether there wis a method like this in SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because if use sub code if the sub code part used repeatedly in one program will save lots of code space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know we can create&amp;nbsp; macros for these sub codes part,BUT a macro must be defined before use of it ,while a sub code could be put in any place of the program.(I have this idea from&amp;nbsp; other programming&amp;nbsp; language,I know SAS read dataset from top to bottom row by row,I hope SAS could read&amp;nbsp; program code in a more flexible way)&lt;/P&gt;&lt;P&gt;Any suggestion will be appreciate!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS code name: NEED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****NEED.SAS****;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*Begin of NEED.sas*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*main program part*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call sub code sub1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call sub code sub2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call sub code sub3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*sub&amp;nbsp; code definition part*/&lt;/P&gt;&lt;P&gt;sub1&lt;/P&gt;&lt;P&gt;proc print data=sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;end sub1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub2&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;x=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;end sub2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub3&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;create table two as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from sashelp.class&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;end sub3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*End of NEED.SAS*/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2012 21:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111035#M30788</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-07-18T21:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code structure available for SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111036#M30789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;looks like a '%Macro' or '%include' or 'call execute' sort of implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2012 21:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111036#M30789</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-18T21:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code structure available for SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111037#M30790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not easily.&lt;/P&gt;&lt;P&gt;SAS works a bit differently so its well worth learning how to deal with it efficiently rather than try and make it work other ways, in my opinion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The %macro and %includes can get you pretty far in terms of automating projects.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2012 22:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111037#M30790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-07-18T22:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code structure available for SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111038#M30791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what the advantage would be.&amp;nbsp; But to be able to do it exactly that way SAS would need to be a compiled language instead of an interpreted one.&amp;nbsp; You could structure your source that way in SCL since it needs to be compiled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really wanted to create code in that form you could wrap the main routine in a macro and then call it at the bottom of the file after all the sub macros have been defined.&amp;nbsp; But I do not recommend it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro main;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %sub1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %sub2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;%mend main;&lt;/P&gt;&lt;P&gt;%macro sub1;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;%mend sub1;&lt;/P&gt;&lt;P&gt;%macro sub2;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;%mend sub2;&lt;/P&gt;&lt;P&gt;%main;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A more natural process would be to create autocall library for the subroutine macros. Create a separate file with each macro's definition and store them in a directory.&amp;nbsp; Then you main program could look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options sasautos=('mymacros');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sub1;&lt;/P&gt;&lt;P&gt;%sub2;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2012 22:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-code-structure-available-for-SAS/m-p/111038#M30791</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-07-18T22:59:02Z</dc:date>
    </item>
  </channel>
</rss>

