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.
%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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment