mirror of
https://github.com/SASPAC/macroarray.git
synced 2025-12-10 09:54:36 +00:00
The macroArray package [ver. 1.2.0]
## The macroArray package [ver. 1.2.0] - New parameters added to the [`%mcDictionary()`](https://github.com/SASPAC/macroarray/blob/main/macroarray.md#mcdictionary-macro) macro which allows to populate dictionary directly from a data set (see the last example in the documentation). - Documentation updated.
This commit is contained in:
@@ -22,7 +22,7 @@ The **macroArray** package implements an array, a hash table, and a dictionary c
|
||||
);
|
||||
```
|
||||
|
||||
SHA256 digest for the latest version of `macroArray`: F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50
|
||||
SHA256 digest for the latest version of `macroArray`: F*8689194590698F9A00B57FB37BE3CA8D7330F16B3E591CEAF49E6BE0B70D61D0
|
||||
|
||||
[**Documentation for macroArray**](./macroarray.md "Documentation for macroArray")
|
||||
|
||||
|
||||
2285
hist/1.2.0/macroarray.md
Normal file
2285
hist/1.2.0/macroarray.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.2.0/macroarray.zip
Normal file
BIN
hist/1.2.0/macroarray.zip
Normal file
Binary file not shown.
@@ -19,7 +19,7 @@
|
||||
|
||||
---
|
||||
|
||||
# The macroArray package [ver. 1.1.1] <a name="macroarray-package"></a> ###############################################
|
||||
# The macroArray package [ver. 1.2.0] <a name="macroarray-package"></a> ###############################################
|
||||
|
||||
The **macroArray** package implements a macro array facility:
|
||||
- `%array()`,
|
||||
@@ -75,10 +75,10 @@ Package contains:
|
||||
Required SAS Components:
|
||||
*Base SAS Software*
|
||||
|
||||
*SAS package generated by generatePackage, version 20230904*
|
||||
*SAS package generated by generatePackage, version 20231107*
|
||||
|
||||
The SHA256 hash digest for package macroArray:
|
||||
`F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50`
|
||||
`F*8689194590698F9A00B57FB37BE3CA8D7330F16B3E591CEAF49E6BE0B70D61D0`
|
||||
|
||||
---
|
||||
# Content description ############################################################################################
|
||||
@@ -1556,6 +1556,9 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
||||
%mcDictionary(
|
||||
H
|
||||
<,METHOD>
|
||||
<,DS=>
|
||||
<,K=Key>
|
||||
<,D=Data>
|
||||
)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -1571,6 +1574,18 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
||||
If `DELETE` then the macro dictionary named by `H` and all
|
||||
macrovariables named like "`&H._`" are deleted.
|
||||
|
||||
* `DS=` - *Optional*, if NOT empty then the `&DS.` dataset is used to
|
||||
populate dictionary with keys from variable `&K.` and data
|
||||
from variable `&D.` Works only during declaration.
|
||||
|
||||
* `K=` - *Optional*, if the `&DS.` is NOT empty then `&K.` holds a name of
|
||||
a variable which keeps or an expression which generates keys values.
|
||||
Default is `Key`.
|
||||
|
||||
* `D=` - *Optional*, if the `&DS.` is NOT empty then `&D.` holds a name of
|
||||
a variable which keeps or an expression which generates data values.
|
||||
Default is `Data`.
|
||||
|
||||
---
|
||||
|
||||
### THE CREATED MACRO `%&H.()`: ####################################################
|
||||
@@ -1704,7 +1719,7 @@ See examples below to see use cases.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 2.** Populate macro dictionary from a dataset.
|
||||
**EXAMPLE 2A.** Populate macro dictionary from a dataset "by hand".
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%mcDictionary(CLASS)
|
||||
@@ -1714,6 +1729,7 @@ data _null_;
|
||||
call execute('%CLASS(ADD,key=' !! name !! ',data=' !! age !! ')');
|
||||
run;
|
||||
%put t = %sysevalf(%sysfunc(datetime()) - &t.);
|
||||
%put &=Class_KEYSNUM.;
|
||||
%put _user_;
|
||||
%CLASS(CLEAR)
|
||||
|
||||
@@ -1721,25 +1737,52 @@ run;
|
||||
%mcDictionary(CARS)
|
||||
%let t = %sysfunc(datetime());
|
||||
data _null_;
|
||||
set sashelp.cars;
|
||||
call execute('%CARS(ADD,key=' !! catx("|",make,model,type) !! ',data=' !! MPG_CITY !! ')');
|
||||
set sashelp.cars(obs=42);
|
||||
call execute('%CARS(ADD,key=' !! catx("|",make,model,type) !! ',data=' !! put(MPG_CITY*10,dollar10.2) !! ')');
|
||||
run;
|
||||
%put t = %sysevalf(%sysfunc(datetime()) - &t.);
|
||||
%put &=CARS_KEYSNUM.;
|
||||
%CARS(LIST);
|
||||
|
||||
%put %CARS(F,key=Audi|TT 3.2 coupe 2dr (convertible)|Sports);
|
||||
|
||||
%CARS(CLEAR)
|
||||
%put &=CARS_KEYSNUM.;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 3.** Data portion may require quoting and un-quoting..
|
||||
**EXAMPLE 2B.** Populate macro dictionary from a dataset "automatically".
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%let t = %sysfunc(datetime());
|
||||
%mcDictionary(CLASS,DCL,DS=sashelp.class,k=name,d=_N_)
|
||||
%put t = %sysevalf(%sysfunc(datetime()) - &t.);
|
||||
%put &=CLASS_KEYSNUM.;
|
||||
%put _user_;
|
||||
%CLASS(CLEAR)
|
||||
|
||||
|
||||
%let t = %sysfunc(datetime());
|
||||
%mcDictionary(CARS,DCL,DS=sashelp.cars(obs=42),k=catx("|",make,model,type),d=put(MPG_CITY*10,dollar10.2))
|
||||
%put t = %sysevalf(%sysfunc(datetime()) - &t.);
|
||||
%put &=CARS_KEYSNUM.;
|
||||
%CARS(LIST);
|
||||
|
||||
%put %CARS(F,key=Audi|TT 3.2 coupe 2dr (convertible)|Sports);
|
||||
|
||||
%CARS(CLEAR)
|
||||
%put &=CARS_KEYSNUM.;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 3.** Data portion may require quoting and un-quoting.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%mcDictionary(CODE)
|
||||
%CODE(CLEAR)
|
||||
%CODE(ADD,key=data, data=%str(data test; x = 42; run;))
|
||||
%CODE(ADD,key=proc, data=%str(proc print; run;))
|
||||
%CODE(ADD,key=macro,data=%nrstr(%put *****;))
|
||||
%CODE(ADD,key=macro,data=%nrstr(%put *1*2*3*4*;))
|
||||
|
||||
%CODE(FIND,key=data)
|
||||
%CODE(FIND,key=proc)
|
||||
@@ -1765,6 +1808,7 @@ data _null_;
|
||||
end;
|
||||
run;
|
||||
%put t = %sysevalf(%sysfunc(datetime()) - &t.);
|
||||
%put %AAA(F,key=A555) %AAA(CHECK,key=A555);
|
||||
%put &=AAA_KEYSNUM;
|
||||
%AAA(CLEAR)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -1780,6 +1824,43 @@ run;
|
||||
%mcDictionary(ABCDEFGHIJKLMNOP) %* good;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 6.** More fun with datasets.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
|
||||
data work.metadata;
|
||||
input key :$16. data :$128.;
|
||||
cards;
|
||||
ID ABC-123-XYZ
|
||||
path /path/to/study/data
|
||||
cutoffDT 2023-01-01
|
||||
startDT 2020-01-01
|
||||
endDT 2024-12-31
|
||||
MedDRA v26.0
|
||||
;
|
||||
run;
|
||||
proc print;
|
||||
run;
|
||||
|
||||
%mcDictionary(Study,dcl,DS=work.metadata)
|
||||
|
||||
%put _user_;
|
||||
|
||||
%put *%Study(F,key=ID)**%Study(C,key=ID)*;
|
||||
|
||||
title1 "Study %Study(F,key=ID) is located at %Study(F,key=path)";
|
||||
title2 "it starts %Study(F,key=startDT) and ends %Study(F,key=endDT)";
|
||||
footnote "MedDRA version: %Study(F,key=MedDRA)";
|
||||
|
||||
proc print data=sashelp.class(obs=7);
|
||||
run;
|
||||
|
||||
title;
|
||||
footnote;
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
---
|
||||
|
||||
## >>> `%QzipArrays()` macro: <<< <a name="qziparrays-macro"></a> #######################
|
||||
|
||||
BIN
macroarray.zip
BIN
macroarray.zip
Binary file not shown.
Reference in New Issue
Block a user