I am importing information from an excel file to do a document merge into a letter using a letterhead template. Then I want to export that letter into several separate .RTF files to have separate letters to send out via email. I have been able to create a merged master file on letterhead containing all of the pages using all of the records from the excel file (which I put into a multi page .RTF file called MEMO.rtf):
filename word DDE 'Winword|system' lrecl=1000;
options noxwait noxsync;
filename watermrk "N:\Letterhead.doc";
%let rc=%sysfunc(system(start winword));
data _null_;
file word;
put '[FileOpen.Name = "' "N:\Letterhead.doc" '"]';
put '[Insertfile .Name ="' "N:\MEMO.rtf" '" ]';
put '[FilePageSetup '
'.Orientation =0,'
'.PageWidth ="8.5 in ",'
'.PageHeight ="11.5 in ",'
'.TopMargin ="1 in ",'
'.BottomMargin ="1 in ",'
'.LeftMargin ="1 in ",'
'.RightMargin =1 in "]';
run;
I am getting stuck at how to parse out the multiple records into multiple RTF files. help!
To me this sounds like you really want a Microsoft help site to work with MAILMERGE.
I'd suggest you explore the SAS ODS RTF facility to write your documents instead of coding it yourself: https://documentation.sas.com/?docsetId=odsug&docsetTarget=p1vvsv8ucnjzjnn1wq5wrlp74mdb.htm&docsetVe...
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.