BookmarkSubscribeRSS Feed
yabwon
Onyx | Level 15

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

 

 

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



4 REPLIES 4
yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

Just small update.

Bart

 

The BasePlus package [ver. 1.20.0] is ready.

New macro added.

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.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

Yet another update. 

Bart

 

The BasePlus package [ver. 1.23.0] details here

Three new utility macros for the BasePlus:

  • %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.


Examples:

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)
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

FYI

New release of BasePlus. I added few "one-liners" inspired by latest discussions here at communities.

Bart

 

The BasePlus package [ver. 1.24.0] details here.

Six new utility macros for the BasePlus:

  • %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.


Examples:

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(%' ));
EXAMPLE 6. Simple text replacement:
  %put %tranwrd(Miss Joan Smith,Miss,Ms.);
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1230 views
  • 9 likes
  • 1 in conversation