Create a Metadata Folder in SAS -Programmatically

As a SAS Application Developer, it’s important for me to be able to build and deploy with the minimum of point and click intervention.  After previously automating the creation of a SAS Stored Process, the next step for me was to find a way to put it somewhere without manually creating a folder first.

Inspired by this post from Paul Homes, here is my result:

https://github.com/sasjs/core/blob/main/meta/mm_createfolder.sas

This macro will work on versions of SAS from 9.2 onwards, and has the following features:

  • Will create all necessary parent folders (eg /Shared Data/new1/new2/new3)
  • Error checking at every step
  • Output dataset with uri of generated folder
  • Prevents new ROOT folders being created
The usage looks something like this:

%mm_createfolder(path=/Shared Data/new1/new2/new3)

As with anything like this - the code is without warranty and you mustn’t get narky if your system explodes.  You may raise issues on github though, or let me know directly!