mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-10 08:20:06 +00:00
Documentation updated
Documentation updated: - preprint of SAS Global Forum 2021 article added. - files from the live demo added.
This commit is contained in:
Binary file not shown.
80
SPF/Documentation/Paper_1079-2021/Paper_1079-2021.sas
Normal file
80
SPF/Documentation/Paper_1079-2021/Paper_1079-2021.sas
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*one library "myLib" created in the (same named) subderectory of the "WORK" directory.*/
|
||||||
|
data _null_;
|
||||||
|
length rc0 $ 32767 rc1 rc2 8;
|
||||||
|
lib = "myLib";
|
||||||
|
rc0 = DCREATE(lib, "%sysfunc(pathname(work))/");
|
||||||
|
put rc0 = ;
|
||||||
|
rc1 = LIBNAME(lib, "%sysfunc(pathname(work))/" !! lib, "BASE");
|
||||||
|
rc2 = LIBREF (lib);
|
||||||
|
if rc2 NE 0 then
|
||||||
|
rc1 = LIBNAME(lib, "%sysfunc(pathname(work))", "BASE");
|
||||||
|
run;
|
||||||
|
|
||||||
|
libname myLib LIST;
|
||||||
|
|
||||||
|
/*two FCMP functions: "F1" and "F2", */
|
||||||
|
proc FCMP outlib = work.f.p;
|
||||||
|
function F1(n);
|
||||||
|
return (n+1);
|
||||||
|
endsub;
|
||||||
|
|
||||||
|
function F2(n);
|
||||||
|
return (n+2);
|
||||||
|
endsub;
|
||||||
|
run;
|
||||||
|
options cmplib = work.f;
|
||||||
|
|
||||||
|
/*one numeric format "fmtNum" and informat "infNum", */
|
||||||
|
proc FORMAT;
|
||||||
|
value fmtNum
|
||||||
|
low -< 0 = "negative"
|
||||||
|
0 = "zero"
|
||||||
|
0 <- high = "positive"
|
||||||
|
other = "missing"
|
||||||
|
;
|
||||||
|
invalue infNum
|
||||||
|
"negative" = -1
|
||||||
|
"zero" = 0
|
||||||
|
"positive" = 1
|
||||||
|
"missing" = .
|
||||||
|
other = 42
|
||||||
|
;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/*one exemplary small dataset "myLib.smallDataset", and*/
|
||||||
|
data myLib.smallDataset;
|
||||||
|
do n = ., -1, 0, 1;
|
||||||
|
m = put(n, fmtNum.);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/*one exemplary bigger dataset "myLib.biggerDataset".*/
|
||||||
|
data myLib.biggerDataset;
|
||||||
|
do i = ., -1e6 to 1e6;
|
||||||
|
j = put(i, fmtNum.);
|
||||||
|
k = ranuni(17);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/*two macros: "mcrOne" and "mcrTwo" */
|
||||||
|
%macro mcrOne();
|
||||||
|
%put **Hi! This is macro &sysmacroname.**;
|
||||||
|
data _null_;
|
||||||
|
set myLib.smallDataset;
|
||||||
|
p = f1(n);
|
||||||
|
p + f2(n);
|
||||||
|
put (n p) (= fmtNum.);
|
||||||
|
run;
|
||||||
|
%mend mcrOne;
|
||||||
|
|
||||||
|
%macro mcrTwo(m=mcrOne);
|
||||||
|
%put **This is macro &sysmacroname.**;
|
||||||
|
%put **and I am calling the &m.**;
|
||||||
|
%&m.()
|
||||||
|
|
||||||
|
%put The answer is: %sysfunc(inputn("I don't know...", infNum.));
|
||||||
|
%mend mcrTwo;
|
||||||
|
|
||||||
|
/* %mcrTwo() */
|
||||||
4
SPF/Documentation/Paper_1079-2021/generate_package.sas
Normal file
4
SPF/Documentation/Paper_1079-2021/generate_package.sas
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
filename packages "~/saspackages";
|
||||||
|
%include packages(SPFinit.sas);
|
||||||
|
|
||||||
|
%generatePackage(~/saspackages/myPackage)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
filename packages "~/saspackages";
|
||||||
|
|
||||||
|
filename SPFinit url
|
||||||
|
"https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas";
|
||||||
|
%include SPFinit;
|
||||||
|
|
||||||
|
%installPackage(SPFinit)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`myLib` library
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
length rc0 $ 32767 rc1 rc2 8;
|
||||||
|
lib = "myLib";
|
||||||
|
rc0 = DCREATE(lib, "%sysfunc(pathname(work))/");
|
||||||
|
put rc0 = ;
|
||||||
|
rc1 = LIBNAME(lib, "%sysfunc(pathname(work))/" !! lib, "BASE");
|
||||||
|
rc2 = LIBREF (lib);
|
||||||
|
if rc2 NE 0 then
|
||||||
|
rc1 = LIBNAME(lib, "%sysfunc(pathname(work))", "BASE");
|
||||||
|
run;
|
||||||
|
|
||||||
|
libname myLib LIST;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`F1` function
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
function F1(n);
|
||||||
|
return (n+1);
|
||||||
|
endsub;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`F2` function
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
function F2(n);
|
||||||
|
return (n+2);
|
||||||
|
endsub;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`fmtNum` format
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
value fmtNum
|
||||||
|
low -< 0 = "negative"
|
||||||
|
0 = "zero"
|
||||||
|
0 <- high = "positive"
|
||||||
|
other = "missing"
|
||||||
|
;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`infNum` informat
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
invalue infNum
|
||||||
|
"negative" = -1
|
||||||
|
"zero" = 0
|
||||||
|
"positive" = 1
|
||||||
|
"missing" = .
|
||||||
|
other = 42
|
||||||
|
;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`myLib.smallDataset` data
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
data myLib.smallDataset;
|
||||||
|
do n = ., -1, 0, 1;
|
||||||
|
m = put(n, fmtNum.);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`myLib.biggerDataset` data
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
data myLib.biggerDataset;
|
||||||
|
do i = ., -1e6 to 1e6;
|
||||||
|
j = put(i, fmtNum.);
|
||||||
|
k = ranuni(17);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
`mcrOne` macro
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
%macro mcrOne();
|
||||||
|
%put **Hi! This is macro &sysmacroname.**;
|
||||||
|
data _null_;
|
||||||
|
set myLib.smallDataset;
|
||||||
|
p = f1(n);
|
||||||
|
p + f2(n);
|
||||||
|
put (n p) (= fmtNum.);
|
||||||
|
run;
|
||||||
|
%mend mcrOne;
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
## General Info: ##
|
||||||
|
|
||||||
|
The `%mcrTwo()` macro is the main macro of the package.
|
||||||
|
|
||||||
|
It has one key-value parameter `m` with default value `mcrOne`.
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
%macro mcrTwo(m=mcrOne);
|
||||||
|
%put **This is macro &sysmacroname.**;
|
||||||
|
%put **and I am calling the &m.**;
|
||||||
|
%&m.()
|
||||||
|
|
||||||
|
%put The answer is: %sysfunc(inputn("I don't know...", infNum.));
|
||||||
|
%mend mcrTwo;
|
||||||
|
|
||||||
|
/*** HELP START ***/
|
||||||
|
/*
|
||||||
|
## Examples: ##
|
||||||
|
|
||||||
|
Example 1. Basic use-case:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
%mcrTwo(m=mcrOne)
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
*/
|
||||||
|
/*** HELP END ***/
|
||||||
21
SPF/Documentation/Paper_1079-2021/myPackage/description.sas
Normal file
21
SPF/Documentation/Paper_1079-2021/myPackage/description.sas
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Type: Package
|
||||||
|
Package: myPackage
|
||||||
|
Title: My first SAS package.
|
||||||
|
Version: 1.0
|
||||||
|
Author: John Smith (john.smith@mail.com)
|
||||||
|
Maintainer: Jane Smith (jane.smith@mail.com)
|
||||||
|
License: MIT
|
||||||
|
Encoding: UTF8
|
||||||
|
|
||||||
|
Required: "Base SAS Software"
|
||||||
|
|
||||||
|
DESCRIPTION START:
|
||||||
|
## The myPackage ##
|
||||||
|
|
||||||
|
The `myPackage` is my first SAS package and
|
||||||
|
for sure it won't be the last package!
|
||||||
|
It was created during SAS Global Forum 2021
|
||||||
|
virtual event.
|
||||||
|
|
||||||
|
It helps me to share my code with other SAS users!
|
||||||
|
DESCRIPTION END:
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
%mcrTwo(m=mcrOne)
|
||||||
14
SPF/Documentation/Paper_1079-2021/mypackage.md
Normal file
14
SPF/Documentation/Paper_1079-2021/mypackage.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## General Info: ##
|
||||||
|
|
||||||
|
The `%mcrTwo()` macro is the main macro of the package.
|
||||||
|
|
||||||
|
It has one key-value parameter `m` with default value `mcrOne`.
|
||||||
|
|
||||||
|
## Examples: ##
|
||||||
|
|
||||||
|
Example 1. Basic use-case:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
%mcrTwo(m=mcrOne)
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Reference in New Issue
Block a user