Hey SAS-C.
The BasePlus package [ver. 1.19.0] package is here.
Intro:
Within last month it happened twice (here and here) that I suggested Kurt Bremser's (@Kurt_Bremser) article "Talking to Your Host" (presented at WUSS 2022 conference) as a solution to a particular task. The task was more or less "extract list of files and subdirectories of a given directory and do something with that list".
Since "used twice" means "repeatable" - I decided to wrap-up Kurt's code into a macro and add it to the BasePlus package.
Changes:
The %dirsAndFiles()
macro was added to the package. The macro allows to extract info about all files and subdirectories of a given root
directory into a data set, for example:
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result)
Macro has several additional parameters which allows to alter the result data set. The macro and the parameters are described in the documentation.
Let me know if you find it useful. 🙂
All the best
Bart
Small update.
New version of SAS Packages Framework was released, note here: https://communities.sas.com/t5/SAS-Programming/SAS-Packages-Framework-version-20230411/m-p/869151#M3...
and also the BasePlus was regenerated. Current version is 1.19.1
Bart
Just small update.
Bart
The %repeatTxt()
utility macro function allows to repeat n
times a text
string separated by string s=
, for example:
%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$);
data work.cars5;
set
%repeatTxt(sashelp.cars, 5)
;
run;
Documentation updated.
Yet another update.
Bart
1.23.0
] details here%intsList()
- prints a space separated list of integers %splitDSIntoBlocks()
- splits dataset into block of given size (and one[the last] possibly smaller) %splitDSIntoParts()
- splits dataset into given number of parts (of approximately same size)Macros splitDSIntoBlocks
and splitDSIntoParts
supports BASE and SPDE engines.
Documentation updated.
EXAMPLE 1: Print integer list from 17 to 42 by 1:
%put %intsList(17,42);
EXAMPLE 2: Split sashelp.class
dataset into blocks of 5 observations:
%splitDSIntoBlocks(5, sashelp.class, classBlock)
EXAMPLE 3: Split sashelp.cars
dataset into 7 parts:
%splitDSIntoParts(7, sashelp.cars, carsPart)
FYI
New release of BasePlus. I added few "one-liners" inspired by latest discussions here at communities.
Bart
1.24.0
] details here.%letters()
- allows to print a list of Roman letters,%filePath()
- from fileref returns path to a file,%libPath()
- from libref returns path to a library,%workPath()
- returns path to the WORK
library,%translate()
- a wrapper to translate() function,%tranwrd()
- a wrapper to tranwrd() function.Documentation updated.
EXAMPLE 1. Every third lowercase letter, i.e. a d g j m p s v y
:
%put %letters(1:26:3,c=L);
EXAMPLE 2. Return path to temporary file:
filename f temp;
%put %filePath(f);
EXAMPLE 3. Return path to SASHELP
library:
%put %libPath(SASHELP);
EXAMPLE 4. Create new library inside WORK
library:
options dlCreateDir;
libname NEW "%workPath()/new";
EXAMPLE 5. Replace quotes and commas with apostrophes and spaces:
%put %translate(%str("A","B","C"),%str(%",),%str(%' ));
%put %tranwrd(Miss Joan Smith,Miss,Ms.);
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.