Hey SAS-C!
"Trick or treat" season is in bloom and the SPF has a new treat for developers.
This release "treat" is brand new utility macro that allows you to do some usefully "tricks" when you want to create a packages structure from "one-big-code" file. Details below.
All the best
Bart
20241027
New simple utility macro: %splitCodeForPackage()
added to the framework. Now we have a dozen!
The macro is a "helping-hand" for those developers who have a "one-big-code" file and want to turn it into a package structure (separate files in subdirectories) but are to lazy to do it manually. Whit help of additional tags
the macro automatically splits the code file according to the developer's wish.
Run:
%splitCodeForPackage(HELP)
to see more details or, probably even better, visit the Documentation and Hands-on-Workshops materials to learn how %splitCodeForPackage()
works .
Example:
Let's assume that the myPackageCode.sas
file is located in the C:/lazy/
folder and contain the following code and tags:
/*##$##-code-block-start-##$## 01_macro(abc) */
%macro abc();
%put I am "abc".;
%mend abc;
/*##$##-code-block-end-##$## 01_macro(abc) */
/*##$##-code-block-start-##$## 01_macro(efg) */
%macro efg();
%put I am "efg".;
%mend efg;
/*##$##-code-block-end-##$## 01_macro(efg) */
proc FCMP outlib=work.f.p;
/*##$##-code-block-start-##$## 02_functions(xyz) */
function xyz(n);
return(n**2 + n + 1)
endfunc;
/*##$##-code-block-end-##$## 02_functions(xyz) */
quit;
and we want results in C:/split/
folder. We run the following:
filename packages "C:/SAS_PACKAGES"; %* a directory for the framework and packages;
%include packages(SPFinit.sas); %* enable the framework;
%splitCodeForPackage(
codeFile=C:/lazy/myPackageCode.sas
,packagePath=C:/split/ )
As a result two subdirectories 01_macro
and 02_functions
are created inside C:/split/
. The first contains two files: abc.sas
and efg.sas
with corresponding macros definitions, the second contains xyz.sas
file with definition of the xyz
function.
Nesting, overlapping, and multiple file redirection is supported.
Here is the link to a list of recordings about SAS Packages framework: https://github.com/yabwon/SAS_PACKAGES?tab=readme-ov-file#recordings-and-presentations
The latest one is: "SAS Packages Framework - an easy code sharing medium for SAS" - Warsaw IT Days 2023 (March 31st 2023, ~60 minutes, general overview with technical details for user and developer)
Here is the link to materials form workshops on the topic ("from 0 to Hero"): https://github.com/yabwon/HoW-SASPackages
Bart
SAS Packages Framework, version 20241102
https://communities.sas.com/t5/SAS-Programming/SAS-Packages-Framework-version-20241102/td-p/949786
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.