27 %macro mm_createfolder(path=,mDebug=0);
    28 %local dbg errorcheck;
    29 %
if &mDebug=0 %then %let dbg=*;
    33   length objId parentFolderObjId objType parent child $200
    35   call missing (of _all_);
    36   folderPath = cats(symget(
'path'));
    38   * 
remove any trailing slash ;
    39   if ( substr(folderPath,length(folderPath),1) = 
'/' ) then
    40     folderPath=substr(folderPath,1,length(folderPath)-1);
    42   * name must not be blank;
    43   if ( folderPath = 
'' ) then 
do;
    44     put 
"%str(ERR)OR: &sysmacroname PATH parameter value must be non-blank";
    47   * must have a starting slash ;
    48   if ( substr(folderPath,1,1) ne 
'/' ) then 
do;
    49     put 
"%str(ERR)OR: &sysmacroname PATH parameter value must have starting slash";
    53   * check 
if folder already exists ;
    54   rc=metadata_pathobj(
'',cats(folderPath,
"(Folder)"),
"",objType,objId);
    56     put 
"NOTE: Folder " folderPath 
" already exists!";
    60   * 
do not create a root (one level) folder ;
    61   if countc(folderPath,
'/')=1 then 
do;
    62     put 
"%str(ERR)OR: &sysmacroname will not create a new ROOT folder";
    66   * check that parent folder exists ;
    67   child=scan(folderPath,-1,
'/');
    68   parent=substr(folderpath,1,length(folderpath)-length(child)-1);
    70   rc=metadata_pathobj(
'',cats(parent,
"(Folder)"),
"",objType,parentFolderObjId);
    72     put 
"%str(ERR)OR: &sysmacroname: parent folder does not exist! " parent;
    77   call symputx(
'parentFolderObjId',parentFolderObjId,
'l');
    78   call symputx(
'child',child,
'l');
    79   call symputx(
'errorcheck',0,
'l');
    84 %
if &errorcheck=1 %then %
return;
    88 filename __newdir temp;
    89 options noquotelenmax;
    91 %let inmeta=<AddMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata>
    92   <Tree Name=
'&child' PublicType=
'Folder' TreeType=
'BIP Folder' UsageVersion=
'1000000'>
    93   <ParentTree><Tree ObjRef=
'&parentFolderObjId'/></ParentTree></Tree></Metadata>
    94   <NS>SAS</NS><Flags>268435456</Flags></AddMetadata>;
    96 proc metadata in=
"&inmeta"   100 %
if &mDebug ne 0 %then %
do;
   103     infile __newdir lrecl=32767;
   109 filename __newdir clear;