Skip to content

Instantly share code, notes, and snippets.

@rudvfaden
Created June 1, 2023 09:56
Show Gist options
  • Save rudvfaden/fa59c09e8f53e625cf73b0c77a24ced6 to your computer and use it in GitHub Desktop.
Save rudvfaden/fa59c09e8f53e625cf73b0c77a24ced6 to your computer and use it in GitHub Desktop.

Revisions

  1. rudvfaden created this gist Jun 1, 2023.
    15 changes: 15 additions & 0 deletions embed.sas
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    %macro embed(f);
    %local p ref rc fid;
    %let p = %sysfunc(findc(&f,/\:.));
    %if &p %then %let rc = %sysfunc(filename(ref, &f));
    %else %let ref = &f;
    %let fid = %sysfunc(fopen(&ref));
    %if &fid>0 %then
    %do %while(%sysfunc(fread(&fid))=0);
    %let rc = %sysfunc(fget(&fid, line, 32767));
    &line
    %end;
    %else %put ERROR: Macro &sysmacroname - file "&f" cannot be opened.;
    %let rc = %sysfunc(fclose(&fid));
    %if &p %then %let rc = %sysfunc(filename(ref));
    %mend embed;