Usually the first files that you create are the source files that define the SAS/IML modules that you will distribute.
You can use .sas
or .iml
as the extension for a source file. For more information about file extensions, see the section Naming Source Files. This documentation uses the .iml
extension.
In the
source
directory, create a file named RightTriangle.iml
. (Notice that the case of this filename matches the case that was specified in the info.txt
file.) Include the following SAS/IML statements in the file. Notice that the file does not contain the PROC IML or QUIT statements.
/* Modules for the RightTriangle package */ /* Do NOT include the PROC IML or QUIT statements! */ /* Given a vector that contains the three side lengths of a triangle, this function returns 1 if the triangle is a right triangle and 0 otherwise. */ start IsRightTriangle(vert); v = colvec(vert); call sort(v, 1); a = v[1]; b = v[2]; c = v[3]; return ( a##2 + b##2 = c##2 ); finish; /* Given the lengths of the hypotenuse and a leg of a right triangle, this function finds the length of the other leg. */ start FindLeg(v); b = min(v); c = max(v); d = c##2 - b##2; if d>0 then return( sqrt(d) ); else return( . ); finish; /* Given the lengths of two legs of a right triangle, this function finds the length of the hypotenuse. */ start FindHypotenuse(v); b = max(v); a = min(v); return( sqrt(a##2 + b##2) ); finish;
Save the RightTriangle.iml
file. When the package is loaded, this file will be read and these functions will be defined.
Note: This procedure is experimental .