SAS Macro does not permit DATALINES, nor even PARMCARDS - they don't survive macro compilation.
However, thanks to a SAS-L post by Richard DeVenezia it was discovered that you CAN create datasets using SAS Macro using a 'trick' in the compilation process!
TLDR; - stick your datalines UNDERNEATH the macro definition and it will run during compilation. If your definition deletes itself, then it will compile each time :-)
/** * setup temporary autocall location * - yours may be permanent */ %let loc=%sysfunc(pathname(work))/myloc; options dlcreatedir; libname _ "&loc"; libname _ clear; options insert=(sasautos=("&loc")); /** * put a macro there * - yours can be written directly */ filename FT15F001 "&loc/richardyoulegend.sas"; parmcards4; %macro richardyoulegend(); proc catalog catalog=work.sasmac1; delete richardyoulegend.macro; quit /* NOTE - missing semicolon */ %mend; /** * put your datalines here! * - they will execute on compilation */ data _data_; /* DATA1 / DATA2 / DATA3 */ input name $ age $; datalines; John 42 Mary 104 ; run; ;;;;
You can now call your macro multiple times, to create multiple datasets! NOTE - you will need to include the semicolon to trigger the macro deletion OUTSIDE the macro.
%richardyoulegend(); %richardyoulegend(); %richardyoulegend();