<?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: BIg Data Module 2. Chapter 5 - Methods, Packages, Threads in SAS Academy for Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585649#M437</link>
    <description>&lt;P&gt;1. Methods are named executable blocks of DS2 code. Methods are executed by DATA and THREAD programs. You can either define the method right in the DATA or THREAD program, or you can store several methods in a PACKAGE. The Package can then be instantiated in the DATA or DTREAD program, and the METHOD code accessed from the package as an alternative to re-writing the METHOD code for each THREAD or DATA program that requires the method.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. As you stated, the method &lt;STRONG&gt;ourGMP&lt;/STRONG&gt;&amp;nbsp;definition (code) is stored in the package &lt;STRONG&gt;work.pkg_05s08&lt;/STRONG&gt;. So now the method is contained in the package.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. The thread &lt;STRONG&gt;work.th_05s08&lt;/STRONG&gt; is defined using the "thread ..endthread"&amp;nbsp; block syntax. Within this thread, package &lt;STRONG&gt;work.pkg_05s08&amp;nbsp;&lt;/STRONG&gt;is instantiated as &lt;STRONG&gt;myPkg&lt;/STRONG&gt;, giving the THREAD program access to the methods stored in the package.&amp;nbsp; The assignment statement GrossMargin = &lt;STRONG&gt;myPkg.ourGMP(&lt;/STRONG&gt;GrossSales, CostofGoods);&amp;nbsp; accesses the &lt;STRONG&gt;ourGMP&lt;/STRONG&gt; method from &lt;STRONG&gt;myPkg&lt;/STRONG&gt; to perform the calculation. (Yes, there a difference between declaration and instantiation of a package - see the material related to the SQLSTMT package later in this chapter - that section explains the difference.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Finally, the THREAD program is executed in parallel from a DATA program. A DATA program that does not specify a desitnation for the result set (&lt;STRONG&gt;data;&lt;/STRONG&gt;) will produce a report instead of an output data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Sep 2019 18:30:00 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2019-09-02T18:30:00Z</dc:date>
    <item>
      <title>BIg Data Module 2. Chapter 5 - Methods, Packages, Threads</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585404#M434</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure that I understand fully how the following work together:&lt;/P&gt;&lt;P&gt;- method&lt;/P&gt;&lt;P&gt;- package&lt;/P&gt;&lt;P&gt;- thread&lt;/P&gt;&lt;P&gt;- data statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please tell me where I am right and where I am wrong.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer to the attached ds2 program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. There seems to be a strict sequence in which these are constructed/defined,&amp;nbsp; declared/instantiated&amp;nbsp; and finally executed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;method -&amp;gt; package -&amp;gt; thread -&amp;gt; data;&amp;nbsp; Can there be situations where this sequence is different ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The method ourGMP and the package work.pkg_05s08 are set up ( defined) in the first few lines of the attached program. The method is contained in the package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. In the second part of the program, the thread work.th_05s08 is defined using the "thread ..endthread"&amp;nbsp; block syntax. Within this thread, the method and package defined above are declared/instantiated&amp;nbsp; ( Is there a difference between declare and instantiate ? )&lt;/P&gt;&lt;P&gt;and then executed together in the statement :&lt;/P&gt;&lt;P&gt;GrossMargin = myPkg.ourGMP(GrossSales, CostofGoods);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. In the final part of the program, the thread is executed in a data step. I am not sure why "data;" is used here and not "data _null_ " or even "data &amp;lt;datasetname&amp;gt; . I guess the &amp;lt;datasetname&amp;gt; option would be used if we were outputting a dataset name. Is this correct ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Odesh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Aug 2019 11:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585404#M434</guid>
      <dc:creator>odesh</dc:creator>
      <dc:date>2019-08-31T11:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: BIg Data Module 2. Chapter 5 - Methods, Packages, Threads</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585649#M437</link>
      <description>&lt;P&gt;1. Methods are named executable blocks of DS2 code. Methods are executed by DATA and THREAD programs. You can either define the method right in the DATA or THREAD program, or you can store several methods in a PACKAGE. The Package can then be instantiated in the DATA or DTREAD program, and the METHOD code accessed from the package as an alternative to re-writing the METHOD code for each THREAD or DATA program that requires the method.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. As you stated, the method &lt;STRONG&gt;ourGMP&lt;/STRONG&gt;&amp;nbsp;definition (code) is stored in the package &lt;STRONG&gt;work.pkg_05s08&lt;/STRONG&gt;. So now the method is contained in the package.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. The thread &lt;STRONG&gt;work.th_05s08&lt;/STRONG&gt; is defined using the "thread ..endthread"&amp;nbsp; block syntax. Within this thread, package &lt;STRONG&gt;work.pkg_05s08&amp;nbsp;&lt;/STRONG&gt;is instantiated as &lt;STRONG&gt;myPkg&lt;/STRONG&gt;, giving the THREAD program access to the methods stored in the package.&amp;nbsp; The assignment statement GrossMargin = &lt;STRONG&gt;myPkg.ourGMP(&lt;/STRONG&gt;GrossSales, CostofGoods);&amp;nbsp; accesses the &lt;STRONG&gt;ourGMP&lt;/STRONG&gt; method from &lt;STRONG&gt;myPkg&lt;/STRONG&gt; to perform the calculation. (Yes, there a difference between declaration and instantiation of a package - see the material related to the SQLSTMT package later in this chapter - that section explains the difference.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Finally, the THREAD program is executed in parallel from a DATA program. A DATA program that does not specify a desitnation for the result set (&lt;STRONG&gt;data;&lt;/STRONG&gt;) will produce a report instead of an output data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 18:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585649#M437</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2019-09-02T18:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: BIg Data Module 2. Chapter 5 - Methods, Packages, Threads</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585838#M439</link>
      <description>Thanks Mark. Three follow-up questions:&lt;BR /&gt;&lt;BR /&gt;1. Can I think of a rough "hierarchy" (top to bottom) comprising:&lt;BR /&gt;Data&lt;BR /&gt;Thread&lt;BR /&gt;Package&lt;BR /&gt;Method&lt;BR /&gt;Function .&lt;BR /&gt;&lt;BR /&gt;2. But then the function SQLEXEC can be used to run a FedSQL query. Would&lt;BR /&gt;this fact contradict the "hierarchy" above ?&lt;BR /&gt;&lt;BR /&gt;3. Are packages always contained in threads or can we build a thread within&lt;BR /&gt;a package ?&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;Odesh.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Sep 2019 14:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/585838#M439</guid>
      <dc:creator>odesh</dc:creator>
      <dc:date>2019-09-03T14:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: BIg Data Module 2. Chapter 5 - Methods, Packages, Threads</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/587083#M441</link>
      <description>&lt;P&gt;Odesh,&lt;/P&gt;
&lt;P&gt;I like the hierarchy idea you laid out in question #1. To view the DS2 ecosystem in this vein, just add the rule that lower-level items in the&amp;nbsp;hierarchy may be used as components in higher level items, but not vice-versa. So, for example, a method may include a function, and method may subsequently become part of a package, thread or data program. But a method &lt;EM&gt;cannot&lt;/EM&gt; contain a package, thread or data program. I think this paradigm also speaks to question #3 - while a packages may be declared (used) in a thread or data program, the package cannot incorporate a thread or data program within the package.&lt;/P&gt;
&lt;P&gt;As for question #2, I see no conflict with the hierarchy model described. A function is just a means of executing a particular task, and SQLEXEC fits well within the definition. According to the&amp;nbsp;hierarchy, SQLEXEC could be used in a method, package, thread or data program - and this is true.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 16:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/BIg-Data-Module-2-Chapter-5-Methods-Packages-Threads/m-p/587083#M441</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2019-09-08T16:20:36Z</dc:date>
    </item>
  </channel>
</rss>

