<?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: PROC DS2 Packages Automatic Methods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944430#M370033</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;I've used this type of code before in DS2 programs but have never seen it documented. I'll attempt to find out why...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2024 14:31:50 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2024-09-18T14:31:50Z</dc:date>
    <item>
      <title>PROC DS2 Packages Automatic Methods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944288#M370005</link>
      <description>&lt;P&gt;I've become interested in the PROC DS2 package functionality and have been trying to learn as much as I can.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm reading this paper right now for reference:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings16/7280-2016.pdf" target="_self"&gt;https://support.sas.com/resources/papers/proceedings16/7280-2016.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the paper, the author talks about how SAS automatically includes getter and setter methods in packages that can be called by adding the prefix "get_" or "set_". My question, is there any documentation on the methods that are automatically included in packages?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, in the paper (bottom of page 6, top of page 7) they create a teacher package which "inherits" from the person package. At one point they reference "get_pname" to get the name from the person package and I was wondering if "get_p" is a predefined prefix? or is there something I'm missing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 16:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944288#M370005</guid>
      <dc:creator>slacey</dc:creator>
      <dc:date>2024-09-17T16:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 Packages Automatic Methods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944358#M370011</link>
      <description>&lt;P&gt;I may be wrong but it seems that in the doc. this is the only place where "get_" pops-up:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ds2pg/n0uuczirxf453en14a69dnwl3kyp.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ds2pg/n0uuczirxf453en14a69dnwl3kyp.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;in&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;next = cur.get_next();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but it does not mention anything about getters or setters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the article is 100% accurate, this code (extended version of the paper one):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
run;

Proc ds2;
 package counter / overwrite=yes;
 dcl int Bvalue;

 method counter();
  Bvalue=0;
 end;

 method add();
  Bvalue=Bvalue+1;
 end;

 endpackage;

 package gluerer / overwrite=yes;
 dcl varchar(1024) Gvalue;

 method counter();
  Gvalue='';
 end;

 method add();
  Gvalue=Strip(Gvalue)!!'+';
 end;

 endpackage;
run;


data _null_;
 dcl package counter boycounter();
 dcl package gluerer girlcounter();
 dcl int nummales;
 dcl varchar(1024) charfemales;

 method init();
  boycounter.set_Bvalue(100);
  girlcounter.set_Gvalue('***');
 end;


 method run();
  set class;
    put sex=;
    if sex='M' then boycounter.add();
               else girlcounter.add();
 end;

 method term();
   nummales=boycounter.get_Bvalue();
   charfemales=girlcounter.get_Gvalue();
   put nummales= charfemales=;
 end;
enddata;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;gives the following log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data class;
2     set sashelp.class;
3    run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


4
5    Proc ds2;
NOTE: Writing HTML Body file: sashtml.htm
6     package counter / overwrite=yes;
7     dcl int Bvalue;
8
9     method counter();
10     Bvalue=0;
11    end;
12
13    method add();
14     Bvalue=Bvalue+1;
15    end;
16
17    endpackage;
18
19    package gluerer / overwrite=yes;
20    dcl varchar(1024) Gvalue;
21
22    method counter();
23     Gvalue='';
24    end;
25
26    method add();
27     Gvalue=Strip(Gvalue)!!'+';
28    end;
29
30    endpackage;
31   run;
NOTE: Created package counter in data set work.counter.
NOTE: Created package gluerer in data set work.gluerer.
NOTE: Execution succeeded. No rows affected.
32
33
34   data _null_;
35    dcl package counter boycounter();
36    dcl package gluerer girlcounter();
37    dcl int nummales;
38    dcl varchar(1024) charfemales;
39
40    method init();
41     boycounter.set_Bvalue(100);
42     girlcounter.set_Gvalue('***');
43    end;
44
45
46    method run();
47     set class;
48       put sex=;
49       if sex='M' then boycounter.add();
50                  else girlcounter.add();
51    end;
52
53    method term();
54      nummales=boycounter.get_Bvalue();
55      charfemales=girlcounter.get_Gvalue();
56      put nummales= charfemales=;
57    end;
58   enddata;
59   run;
Sex=M
Sex=F
Sex=F
Sex=F
Sex=M
Sex=M
Sex=F
Sex=F
Sex=M
Sex=M
Sex=F
Sex=F
Sex=F
Sex=F
Sex=M
Sex=M
Sex=M
Sex=M
Sex=M
nummales=110 charfemales=***+++++++++
NOTE: Execution succeeded. No rows affected.
60   quit;

NOTE: PROCEDURE DS2 used (Total process time):
      real time           0.16 seconds
      cpu time            0.14 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 08:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944358#M370011</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-09-18T08:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 Packages Automatic Methods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944407#M370024</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mark, maybe you will be able to help here?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 13:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944407#M370024</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-09-18T13:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 Packages Automatic Methods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944430#M370033</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;I've used this type of code before in DS2 programs but have never seen it documented. I'll attempt to find out why...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 14:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944430#M370033</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-09-18T14:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 Packages Automatic Methods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944492#M370052</link>
      <description>&lt;P&gt;Appreciate both the replies. Unfortunate that the feature isn't really documented since having automatic generation of getters and setters would seem to be useful functionality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concerning my other question about the "get_pname()" statement. I had been wondering if the "get_p" prefix was an auto generated parent getter but, I just ran through the code, it seems like it's just a typo and should have been "get_name()".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 18:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-DS2-Packages-Automatic-Methods/m-p/944492#M370052</guid>
      <dc:creator>slacey</dc:creator>
      <dc:date>2024-09-18T18:49:55Z</dc:date>
    </item>
  </channel>
</rss>

