Sample 51746: Creating DS2 overloaded methods in a permanent package
The sample code on the Full Code tab demonstrates how to create DS2 packages with overloaded methods and store them in a permanent library.
More information on DS2 methods and packages can be found at:
DS2 Methods
DS2 Packages
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The sample code below demonstrates how to create DS2 packages with overloaded methods and store them in a permanent library.
libname ds2_pkg 'your_permanent_location';
proc ds2;
package ds2_pkg.calc_volume / overwrite=yes;
/* Volume of a cube. */
method volume (int side) returns int;
return side*3;
end;
/* Volume of a cyclinder. */
method volume (double radius, int height) returns double;
return 3.14*radius**2*height;
end;
/* Volume of a cuboid. */
method volume (double len, int base, int hgt) returns double;
return len*base*hgt;
end;
endpackage;
run;
data _NULL_;
/* Declare global variables here */
dcl package ds2_pkg.calc_volume v();
dcl int box_side box_volume my_height my_base my_hgt;
dcl double my_radius cylinder_volume my_len cuboid_volume;
method run();
box_side = 4;
box_volume = v.volume(box_side);
put 'volume of box is: ' box_volume;
my_radius = 3.5;
my_height = 9;
cylinder_volume = v.volume(my_radius,my_height);
put 'volume of cylinder is: ' cylinder_volume;
my_len = 90;
my_base = 85;
my_hgt = 20;
cuboid_volume = v.volume(my_len, my_base, my_hgt);
put 'volume of cuboid is: ' cuboid_volume;
end;
enddata;
run;
quit;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
volume of box is: 12
volume of cylinder is: 572.265
volume of cuboid is: 153000
Date Modified: | 2013-12-20 15:37:45 |
Date Created: | 2013-12-04 13:14:15 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.4 TS1M0 | |
Z64 | 9.4 TS1M0 | |
Microsoft® Windows® for x64 | 9.4 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.4 TS1M0 | |
Microsoft Windows 8 Enterprise 32-bit | 9.4 TS1M0 | |
Microsoft Windows 8 Enterprise x64 | 9.4 TS1M0 | |
Microsoft Windows 8 Pro 32-bit | 9.4 TS1M0 | |
Microsoft Windows 8 Pro x64 | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise x64 | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro 32-bit | 9.4 TS1M0 | |
Microsoft Windows Server 2008 R2 | 9.4 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Datacenter | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Datacenter | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Std | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Std | 9.4 TS1M0 | |
Windows 7 Enterprise x64 | 9.4 TS1M0 | |
Windows 7 Professional x64 | 9.4 TS1M0 | |
64-bit Enabled AIX | 9.4 TS1M0 | |
64-bit Enabled HP-UX | 9.4 TS1M0 | |
64-bit Enabled Solaris | 9.4 TS1M0 | |
HP-UX IPF | 9.4 TS1M0 | |
Linux for x64 | 9.4 TS1M0 | |
Solaris for x64 | 9.4 TS1M0 | |