<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to find , how many pages in one rtf file by using SAS code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/819963#M323626</link>
    <description>&lt;P&gt;Not all applications that create RTF files store the number of pages in the document metadata. But if the RTF you are working with was created in Microsoft Word, that information is available as metadata in the RTF file and you can extract it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rtfinfo;
   Length Author $50 Pages Words 8;
   if _n_=1 then do;
      rxAuthor=prxparse('!\\author\s?([^}]*)}!');
      rxDate=prxparse('!\\creatim\s?\\yr(\d*)\\mo(\d*)\\dy(\d*)!');
      rxPages=prxparse('!\\nofpages\s?(\d*)}!');
      rxWords=prxparse('!\\nofwords\s*(\d*)}!');
   end;
   retain rx:;
   drop rx:;
   infile 'C:\temp\myrtf.rtf' end=eof;
   do until (eof);
      input;
      if prxmatch(rxAuthor,_infile_) then do;
         Author=prxposn(rxAuthor,1,_infile_);
         put Author=;
      end;
      if prxmatch(rxPages,_infile_) then do;
         Pages=input(prxposn(rxPages,1,_infile_),32.);
         put Pages=;
      end;
      if prxmatch(rxWords,_infile_) then do;
         Words=input(prxposn(rxWords,1,_infile_),32.);
         put Words=;
      end;
      if sum(missing(Author),missing(Pages),missing(Words))=0 then do;
         output;
         stop;
      end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code produces an output that looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.RTFINFO" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;Author&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Pages&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Words&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;Mark Jordan&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;16&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 23 Jun 2022 12:22:41 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2022-06-23T12:22:41Z</dc:date>
    <item>
      <title>how to find , how many pages in one rtf file by using SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/819937#M323615</link>
      <description>&lt;P&gt;My query is like we have one rtf file . So just i checked manually like 10 pages are there .&amp;nbsp;&lt;BR /&gt;how to do in sas code to find the no.of pages in rtf file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 10:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/819937#M323615</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2022-06-23T10:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to find , how many pages in one rtf file by using SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/819963#M323626</link>
      <description>&lt;P&gt;Not all applications that create RTF files store the number of pages in the document metadata. But if the RTF you are working with was created in Microsoft Word, that information is available as metadata in the RTF file and you can extract it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rtfinfo;
   Length Author $50 Pages Words 8;
   if _n_=1 then do;
      rxAuthor=prxparse('!\\author\s?([^}]*)}!');
      rxDate=prxparse('!\\creatim\s?\\yr(\d*)\\mo(\d*)\\dy(\d*)!');
      rxPages=prxparse('!\\nofpages\s?(\d*)}!');
      rxWords=prxparse('!\\nofwords\s*(\d*)}!');
   end;
   retain rx:;
   drop rx:;
   infile 'C:\temp\myrtf.rtf' end=eof;
   do until (eof);
      input;
      if prxmatch(rxAuthor,_infile_) then do;
         Author=prxposn(rxAuthor,1,_infile_);
         put Author=;
      end;
      if prxmatch(rxPages,_infile_) then do;
         Pages=input(prxposn(rxPages,1,_infile_),32.);
         put Pages=;
      end;
      if prxmatch(rxWords,_infile_) then do;
         Words=input(prxposn(rxWords,1,_infile_),32.);
         put Words=;
      end;
      if sum(missing(Author),missing(Pages),missing(Words))=0 then do;
         output;
         stop;
      end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code produces an output that looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.RTFINFO" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;Author&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Pages&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Words&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;Mark Jordan&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;16&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Jun 2022 12:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/819963#M323626</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-06-23T12:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to find , how many pages in one rtf file by using SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/820163#M323696</link>
      <description>I have a text in one RTF file so I have to read that text into sas and&lt;BR /&gt;create one dataset&lt;BR /&gt;&lt;BR /&gt;text ---&amp;gt; This is awesome</description>
      <pubDate>Thu, 23 Jun 2022 21:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/820163#M323696</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2022-06-23T21:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to find , how many pages in one rtf file by using SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/820512#M323861</link>
      <description>&lt;P&gt;RTF is a format designed to present information best formatted for human consumption and is not well suited for machine-reading. Significant SAS programming and a good knowledge of RTF structure are required to extract data from an RTF. Here are some good references to get you started:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.biblioscape.com/rtf15_spec.htm" target="_self"&gt;RTF file specifications&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://www.lexjansen.com/pharmasug-cn/2017/CC/PharmaSUG-China-2017-CC07.pdf" target="_self"&gt;How to read RTF files into SAS® datasets?&lt;/A&gt; by Chunpeng Zhao&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2010/CC/CC06.pdf" target="_self"&gt;Importing Data from RTF Output into SAS® utilizing Microsoft® Access/Word in&amp;nbsp;an intriguing, efficient way&lt;/A&gt; -&amp;nbsp;Ajay Gupta and&amp;nbsp;Matthew Lesko&lt;/LI&gt;
&lt;LI&gt;The &lt;A href="http://www.sastricks.com/macros/readrtf.sas.txt" target="_self"&gt;readrtf macro&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 27 Jun 2022 12:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-how-many-pages-in-one-rtf-file-by-using-SAS-code/m-p/820512#M323861</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-06-27T12:15:38Z</dc:date>
    </item>
  </channel>
</rss>

