Hello, colleagues.
I'm responsible for randomization, and, in particular, coding. The task I have to complete is to create 2 huge word documents with each page in them serving as a label to be printed later on with the intention to glue it on a cover of an envelope or to be used as the contents of an envelope. This particular study uses envelopes for randomization.
The first document should be like this: each page should have text in the middle with name of the study and whatnot and then the next line would be just the "Envelope number: x
The second document is a bit diffferent: 3 lines in the middle, first line is just the study name, second line is randomization number and third line is the kit number.
In my disposal I got a data set X with 2 columns (randnum, kitnum) and 150 rows. First column is randomization number and second column is the kit number.
The idea I had in mind was to use the %do-loop inside a macro after an "ods rtf file" statement, which would, using a data step, fetch a row of the data set X and then using ods rtf text statement with the startpage = now I'd be able to create the desired document:
The code would look like this:
%macro M;
local i;
%do i = 1 %to 150;
data temp;
set x;
where _N_ = &i;
call symput('randnum',randnum);
call symput('kitnum',kitnum);
run;
ods rtf text "to-be-redacted-when-code-works: &randnum, &kitnum);
/* many other lines to make the pages look approproate */
%end;
%mend M;
options nodate nonumber byline;
ods escapechar = "^";
ods listing close;
ods rtf file = "<my_destination_folder>" startpage=no;
%M;
ods _all_ close;
ods listing;
But sadly the result fails and the myriad of errors tell me that I either do not understand the %do-loop statement or ods rtf statements simply do not work for this purpose.
Could anyone help out to point at the errors or suggest a viable alternative?
Thanks in advance.
I am not sure I am understanding your use of "document".
Are you attempting to create one rtf file with information per page that you will PRINT?
Does this come at all close to what the first requirement may be? I have provided a short dummy data set to process, change the path on the ODS RTF statement to match your need.
data junk; input x kit; label x="Envelope Number"; datalines ; 4 423 257 275 83 888 18 897 ; run; ods rtf file='c:\path\first.rtf' bodytitle notoc_data ; ods noproctitle; options nobyline; proc print data=junk noobs label; title "This is invariate text that would repeat for each page"; title2 "use more title lines if more lines are needed"; by notsorted x; var x; run; ods rtf close;
Hello, colleagues.
I'm very sorry for the long absence but I guess I ought to give this case a closure.
This is the solution that worked for me.
data junk; input randnum kit_number; datalines ; 4 423 257 275 83 888 18 897 ; run;
%macro M;
local i;
%do i = 1 %to 4;
data temp;
set junk;
if _N_ = &i;
call symput('randnum',randnum);
call symput('kitnum',kit_number);
run;
data temp2;
text = " ^n^n^n^n^n^n^n^n^n^n^n^n^n^n^n
Investigation number №: ^S={font_weight=bold} XXXXXXXXXXX ^n^n
^S={font_weight=light}Randomization number: &randnum ^n^n
Kit number: &kitnum";
run;
proc report data=temp2 nowd noheader style(report)={rules=none frame=void}
style(column)={font_size=14pt just=l};
run;
ods startpage = now;
%end;
%mend M;
options nodate nonumber byline orientation=portrait papersize=letter;
ods escapechar = "^";
ods listing close;
ods rtf file = "C:\Users\Username\contents.rtf" startpage=yes;
%M;
ods _all_ close;
ods listing;
The result is 4 pages in rtf file with similar content in the middle of each page. This will be used as contents for envelopes in the blinded randomization trial with appropriate data (150 pages)
Thanks everyone for your input!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: