24     tree=/User Folders/sasdemo
    31 %
if &mDebug=1 %then %let mD=;
    32 %
else %let mD=%str(*);
    33 %&mD.put Executing &sysmacroname..sas;
    38 %let tsuri=stopifempty ;
    41   format type uri tsuri value $200.;
    42   call missing (of _all_);
    43   path=
"&tree/&name(StoredProcess)";
    45   if metadata_pathobj(
"",path,
"StoredProcess",type,uri)>0 then 
do;
    48     do while (metadata_getnasn(uri,
"Notes",cnt,tsuri)>0);
    49       rc=metadata_getattr(tsuri,
"Name",value);
    51       if value=
"SourceCode" then 
do;
    53         rc=metadata_getattr(tsuri,
"Id",value);
    54         call symputx(
'tsuri',value,
'l');
    63 %
if &tsuri=stopifempty %then %
do;
    64   %put WARNING:  &tree/&name.(StoredProcess) not found!;
    72 filename __getdoc temp lrecl=10000000;
    74  in=
"<GetMetadata><Reposid>$METAREPOSITORY</Reposid>    75     <Metadata><TextStore Id='&tsuri'/></Metadata>    76     <Ns>SAS</Ns><Flags>1</Flags><Options/></GetMetadata>"    82   infile __getdoc lrecl=10000;
    84   start=index(_infile_,
'StoredText="');
    86     call symputx(
"start",start+11);
    87     putlog 
'"' _infile_ 
'"';
    92 %
if %length(&outloc)=0 %then %let outeng=TEMP;
    93 %
else %let outeng=
"&outloc";
    95 filename __outdoc &outeng lrecl=100000;
    97  length filein 8 fileid 8;
    98  filein = fopen(
"__getdoc",
"I",1,
"B");
    99  fileid = fopen(
"__outdoc",
"O",1,
"B");
   102  do while(fread(filein)=0);
   105     rc = fget(filein,rec,1);
   106     if rec=
'"' then leave;
   107     else if rec=
"&" then 
do;
   110         if fread(filein) ne 0 then 
goto getout;
   111         rc = fget(filein,rec,1);
   112         entity=cats(entity,rec);
   115         when (
'&' ) rec='&'  ;
   116         when ('<'  ) rec='<'  ;
   117         when ('>'  ) rec='>'  ;
   118         when (''') rec="'"  ;
   119         when ('"') rec='"'  ;
   120         when ('&
#x0a;') rec='0A'x;   121         when (
'
') rec='0D'x;
   122         when ('&
#36;' ) rec='$'  ;   123         otherwise putlog 
"WARNING: missing value for " entity=;
   125       rc =fput(fileid, substr(rec,1,1));
   129       rc =fput(fileid,rec);
   139 %
if &outeng=TEMP %then %
do;
   141     infile __outdoc lrecl=32767;
   147 filename __getdoc clear;
   148 filename __outdoc clear;