<?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 Proc DS2 - Can my package method OUTPUT to the callers output? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-DS2-Can-my-package-method-OUTPUT-to-the-callers-output/m-p/968804#M376644</link>
    <description>&lt;P&gt;I would like to have a package method output a record to the callers output.&lt;/P&gt;
&lt;P&gt;If possible, I can't seem to locate the 'type' that is needed to specify a dataset argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider this simple example (that does not work)&lt;/P&gt;
&lt;PRE&gt;proc ds2 ;
  package MyComplicatedPackage / overwrite=yes ;
    method DoComplicatedRecursiveThings (output aDataset, double _zzz) ;
      aDataset.zzz = _zzz ;
      output aDataset ;
    end ;
  endpackage ;

  data foo / overwrite=yes ;
    declare double zzz ;
    declare package MyComplicatedPackage mcp() ;
    method run () ;
      mcp.DoComplicatedRecursiveThings(foo, 1234) ;
    end ;
  enddata ;
run ;
quit ;&lt;/PRE&gt;
&lt;P&gt;If this was working code, it would create an output data set named foo&lt;/P&gt;
&lt;PRE&gt;foo:
zzz
----
1234&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Jun 2025 04:46:18 GMT</pubDate>
    <dc:creator>RichardAD</dc:creator>
    <dc:date>2025-06-12T04:46:18Z</dc:date>
    <item>
      <title>Proc DS2 - Can my package method OUTPUT to the callers output?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-DS2-Can-my-package-method-OUTPUT-to-the-callers-output/m-p/968804#M376644</link>
      <description>&lt;P&gt;I would like to have a package method output a record to the callers output.&lt;/P&gt;
&lt;P&gt;If possible, I can't seem to locate the 'type' that is needed to specify a dataset argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider this simple example (that does not work)&lt;/P&gt;
&lt;PRE&gt;proc ds2 ;
  package MyComplicatedPackage / overwrite=yes ;
    method DoComplicatedRecursiveThings (output aDataset, double _zzz) ;
      aDataset.zzz = _zzz ;
      output aDataset ;
    end ;
  endpackage ;

  data foo / overwrite=yes ;
    declare double zzz ;
    declare package MyComplicatedPackage mcp() ;
    method run () ;
      mcp.DoComplicatedRecursiveThings(foo, 1234) ;
    end ;
  enddata ;
run ;
quit ;&lt;/PRE&gt;
&lt;P&gt;If this was working code, it would create an output data set named foo&lt;/P&gt;
&lt;PRE&gt;foo:
zzz
----
1234&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jun 2025 04:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-DS2-Can-my-package-method-OUTPUT-to-the-callers-output/m-p/968804#M376644</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2025-06-12T04:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc DS2 - Can my package method OUTPUT to the callers output?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-DS2-Can-my-package-method-OUTPUT-to-the-callers-output/m-p/969511#M376855</link>
      <description>&lt;P&gt;A DS2 method parameter must be one of the supported DS2 data types. DATASET is not a valid datatype.&amp;nbsp; You&amp;nbsp;&lt;EM&gt;can&lt;/EM&gt; use an output statement in the package method to write a row to the dataset that has already been specified in the calling data program.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2 ;
  package MyComplicatedPackage / overwrite=yes ;
    /* IN_OUT parameters are passed by reference. When this method is called,
       you must specify a variable NAME for the parameter instead of a value.
       The value of the variable becomes accessible to, and can be modified by
	   any of the package methods. */
    method DoComplicatedRecursiveThings (in_out double _z) ;
   /* Change the value to the square of the original */
      _z=_z**2;
   /* Output the result to the calling program's data set */
	   output;
    end ;
  endpackage ;

  data foo / overwrite=yes ;
    declare double zzz ;
    declare package MyComplicatedPackage mcp() ;
    method run () ;
      /* Set the initial value of zzz */
	  zzz=1234;
      /* Modify the value and output using the pacakge method */
      mcp.DoComplicatedRecursiveThings(zzz) ;
    end ;
  enddata ;
run ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;TABLE class="table undefined" aria-label="Data Set WORK.FOO"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col" width="25px"&gt;Obs&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="70px"&gt;&amp;nbsp;zzz&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="25px"&gt;1&lt;/TH&gt;
&lt;TD width="70px" class="r data"&gt;1522756&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jun 2025 15:28:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-DS2-Can-my-package-method-OUTPUT-to-the-callers-output/m-p/969511#M376855</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2025-06-22T15:28:30Z</dc:date>
    </item>
  </channel>
</rss>

