BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Brian844
Fluorite | Level 6

Hi Good Day All,

 

We have always been creating reports using "ods rtf file="test.rtf"" to have the titles and footnotes inside of the header and footer section. Recently have have made some updates to our programming to have the footnotes inside of the body of the RTF files instead of in the footer section. We achieved this with a macro that we call inside of proc report "%footnotes;" this footnotes.sas macro basically contains a compute statement and loop through the number of footnotes available for each report and populate the footnotes inside the body of the report.

 

We now have this one client that have some more specific requirements on how their reports should look like and to be compliant with their systems.
they basically now wants the "Protocol Number", "Status", and "Page of x of y", inside of the header section and all other titles + byline in the body of the RTF file.
Now I have again created another macro called Titles.sas that does the same thing as the footnote.sas macro and it works fine.

I want a more general approach and want to make the update to TAGSET.RTF.  When spoken to our client on how they have achieved this they mentioned that they have made the update to TAGSET.RTF and created TAGSET.RTF_CUSTOM. Unfortunately they do not want to share their code :-(.

Does anyone have an idea on how to achieve this. 

 

I have now used ODS TAGSET.RTF File="test.rtf" instead of ODS RTF File="test.rtf", but then  all titles comes in the body section, but I see some utility info ("Protocol Number", "Status", and "Page of x of y") to come up in the header section. and titles 1 to x in the body section.

When using only TAGSET.RTF there is now header section coming at all.

Below is example of what I need

EXAMPLE.JPG

Best regards,

B.

1 ACCEPTED SOLUTION

Accepted Solutions
Brian844
Fluorite | Level 6

Ok, just an update.

After countless of hours and 100s of reruns, I think I have cracked it 🙂 
Here is the updated template code to split the row in the header section.

proc template;
  measured;
  define tagset tagsets.newrtf;
    parent=tagsets.rtf;
    default_style="styles.rtf";

    define event thispage;
      start:
      put NL;
      put "{\trowd";
      put "\cellx3785";
      put "\cellx7723";
      put "\cellx11518";

      /* Cell 1: Left Text - Left-aligned */
      put "\pard\plain\intbl\b\i\sb10\sa10\ql\f1\fs26\cf1{Left Text}" NL;

      /* Cell 2: Center Text - Center-aligned */
      put "\cell";
      put "\pard\plain\intbl\b\i\sb10\sa10\qc\f1\fs26\cf1{Center Text}" NL;

      /* Cell 3: "Page x of y" - Right-aligned */
      put "\cell";
      put "\pard\plain\intbl\b\i\sb10\sa10\qr\f1\fs26\cf1{Page {\field{\*\fldinst { PAGE }}} of {\field{\*\fldinst { NUMPAGES }}}\cell}";

      put "\row}";
    end;
  end;
run;

View solution in original post

6 REPLIES 6
Brian844
Fluorite | Level 6

Just posting an update. in order for our client to achieve this they have used option number with ods tagset.rtf to get the header section with an page number then they have modified that sas auto number for each page to and transformed it into page x of y . not sure exactly how they did it.

ballardw
Super User

Example data in the form of a working data step

Example report code (or use a SAS supplied data set like SASHELP.CLASS in the report)

Example of the desired appearance of the result for that given code and data.

 

I note that you comment about your customer not sharing code but then provide no example code of your own.

If our suggestion is supposed to work with the clients custom style there may not be any solution because we have no idea what they have done to the template that might interact with proposed solutions.

Brian844
Fluorite | Level 6

Ok, This is what I have till now.

 

I have used option 'number' which brought the header section on, in the RTF file.

I have used proc template to change the SAS autonumber from '1' to 'Page x of y' with a "define event thispage" statement. 

proc template;
   measured;
   define tagset tagsets.newrtf;
     parent=tagsets.rtf;
     default_style="styles.rtf" ;
       define event thispage;
         start:
         put "{Page {\field{\*\fldinst { PAGE }}}{ of }{\field{\*\fldinst { NUMPAGES }}}}";
       end;
   end;
run;


I am not sure how to split the line in the header section into 3 columns. If it was a normal title or footnote then I could have used justify=l/c/r, but seeing its an update to the RTF tagset I am unsure how to proceed. I have checked online and there is not a lot of info out there regarding the same. Any help would be greatly appreciated.

 

I have attached the code and output that I currently have.

 - Example.sas (The sas code that generate 'Have.rtf')

- Want.rtf (The desire RFT file. colored sections are what I want)

ballardw
Super User

@Brian844 wrote:

Ok, This is what I have till now.

 

I have used option 'number' which brought the header section on, in the RTF file.

I have used proc template to change the SAS autonumber from '1' to 'Page x of y' with a "define event thispage" statement. 

proc template;
   measured;
   define tagset tagsets.newrtf;
     parent=tagsets.rtf;
     default_style="styles.rtf" ;
       define event thispage;
         start:
         put "{Page {\field{\*\fldinst { PAGE }}}{ of }{\field{\*\fldinst { NUMPAGES }}}}";
       end;
   end;
run;


I am not sure how to split the line in the header section into 3 columns. If it was a normal title or footnote then I could have used justify=l/c/r, but seeing its an update to the RTF tagset I am unsure how to proceed. I have checked online and there is not a lot of info out there regarding the same. Any help would be greatly appreciated.

 

I have attached the code and output that I currently have.

 - Example.sas (The sas code that generate 'Have.rtf')

- Want.rtf (The desire RFT file. colored sections are what I want)


Your template appears to be attempting to use RTF codes and not SAS options in the header.

My limited experience with such is to manually create an RTF document with the desired appearance. Then open that document in a plain text editor like Notepad or the SAS editor and find the section you have created and extract the bits. Suggestion is to make the document as plain as possible, as in nothing else because it is extremely likely that there will be major pile of stupid formatting that appears that has nothing to do with the part that you want.  In your "want" I think what your header looks like is

{\headerr \ltrpar \ltrrow\trowd \irow0\irowband0\ltrrow
\ts11\trqr\trleft0\trkeep\trftsWidth1\trftsWidthB3\trftsWidthA3\tblrsid8150212\tblind0\tblindtype3 \clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \clcbpat19\cltxlrtb\clftsWidth3\clwWidth5040\clcbpatraw19 \cellx5040
\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone \clcbpat20\cltxlrtb\clftsWidth3\clwWidth5040\clcbpatraw20 \cellx10080\clvertalt\clbrdrt\brdrnone \clbrdrl\brdrnone \clbrdrb\brdrnone \clbrdrr\brdrnone 
\clcbpat21\cltxlrtb\clftsWidth3\clwWidth5040\clcbpatraw21 \cellx15120\pard\plain \ltrpar\ql \li0\ri0\sl-230\slmult0\widctlpar\intbl\wrapdefault\faauto\rin0\lin0\pararsid8150212 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs20\lang1033\langfe1033\loch\af0\hich\af0\dbch\af31505\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b\cf1\insrsid8150212 \hich\af0\dbch\af31505\loch\f0 Left Text\cell }\pard \ltrpar\qc \li0\ri0\sl-230\slmult0
\widctlpar\intbl\wrapdefault\faauto\rin0\lin0\pararsid8150212 {\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b\cf1\insrsid8150212 \hich\af0\dbch\af31505\loch\f0 Center Text\cell }\pard \ltrpar\qr \li0\ri0\sl-230\slmult0\widctlpar\intbl\wrapdefault\faauto\rin0\lin0 {
\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b\cf1\insrsid8150212 \hich\af0\dbch\af31505\loch\f0 Page }{\field{\*\fldinst {\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b\cf1\insrsid8150212 \hich\af0\dbch\af31505\loch\f0  PAGE }}{\fldrslt {\rtlch\fcs1 \ab\af0 \ltrch\fcs0 
\b\cf1\lang1024\langfe1024\noproof\insrsid7544390 \hich\af0\dbch\af31505\loch\f0 1}}}\sectd \ltrsect\lndscpsxn\linex0\endnhere\sectdefaultcl\sftnbj {\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b\cf1\insrsid8150212 \hich\af0\dbch\af31505\loch\f0  of }
{\field{\*\fldinst {\rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b\cf1\insrsid8150212 \hich\af0\dbch\af31505\loch\f0  NUMPAGES }}

Where an awful lot of that is in-line text and cell formatting. I have highlighted above in green the bits that are your text. One of the Page, the one in all capital letters, is the RTF page number instruction and the NUMPAGES is the document number of pages.

I suspect that at least have to codes are unlikely to have much affect on your document until the length of the text gets notably longer than your example. The the "wrap within cell", which I think is the "wrapdefault" may come into play. 

 

If those "3 columns" are supposed to align with anything else that may be a lot of fun (read: a pain in the @#$) to modify. I suspect a one-row three cell table might be the approach inserted tab positions may work as well.

Brian844
Fluorite | Level 6

Ok, just an update.

After countless of hours and 100s of reruns, I think I have cracked it 🙂 
Here is the updated template code to split the row in the header section.

proc template;
  measured;
  define tagset tagsets.newrtf;
    parent=tagsets.rtf;
    default_style="styles.rtf";

    define event thispage;
      start:
      put NL;
      put "{\trowd";
      put "\cellx3785";
      put "\cellx7723";
      put "\cellx11518";

      /* Cell 1: Left Text - Left-aligned */
      put "\pard\plain\intbl\b\i\sb10\sa10\ql\f1\fs26\cf1{Left Text}" NL;

      /* Cell 2: Center Text - Center-aligned */
      put "\cell";
      put "\pard\plain\intbl\b\i\sb10\sa10\qc\f1\fs26\cf1{Center Text}" NL;

      /* Cell 3: "Page x of y" - Right-aligned */
      put "\cell";
      put "\pard\plain\intbl\b\i\sb10\sa10\qr\f1\fs26\cf1{Page {\field{\*\fldinst { PAGE }}} of {\field{\*\fldinst { NUMPAGES }}}\cell}";

      put "\row}";
    end;
  end;
run;
manasa1
Calcite | Level 5
Hi, I have a similar request, but my client wants sponsor name in the left side and status in the right side inside of the header section and all titles and byline in the body of the rtf

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 936 views
  • 0 likes
  • 3 in conversation