<?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: Multiple Do Loops, but Single RTF? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161131#M31348</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use of proc document? &lt;A href="https://support.sas.com/documentation/cdl/en/odsug/65308/HTML/default/viewer.htm#n18nmkmj3ed2hrn13i9cwm821blu.htm" title="https://support.sas.com/documentation/cdl/en/odsug/65308/HTML/default/viewer.htm#n18nmkmj3ed2hrn13i9cwm821blu.htm"&gt;SAS(R) 9.3 Output Delivery System: User's Guide, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 May 2014 18:32:06 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2014-05-16T18:32:06Z</dc:date>
    <item>
      <title>Multiple Do Loops, but Single RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161126#M31343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following program that runs a macro for two different periods and two different models. The issue is that each time the loop runs through the macro, a new RTF output gets generated. I was wondering if there was a way to generate a &lt;SPAN style="text-decoration: underline;"&gt;single&lt;/SPAN&gt; RTF document with &lt;SPAN style="text-decoration: underline;"&gt;titles&lt;/SPAN&gt; for each output (for each per and m pairs). I was suggested earlier that I put "ods rtf close" after the second %end, but SAS got stuck (runs forever) after this change. I was also suggested to add "ODS RTF startpage=now" where I identify the location of the RFT output. When I do that, SAS keeps crashing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached the sample sas dataset to this inquiry. Thank you for your time and help in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro twostep;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do per=1 %to 2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do m=1 %to 2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let model1= vret_msa mktrf100;&amp;nbsp;&amp;nbsp;&amp;nbsp; *model specification;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let model2= vret_msa mktrf100 ind_ret;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data perret&amp;amp;per; set a14_samplesas; if period=&amp;amp;per;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=perret&amp;amp;per; by permno myear; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods listing close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods output parameterestimates=pe&amp;amp;per&amp;amp;m;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc reg data=perret&amp;amp;per;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; by permno;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model ereturn_i =&amp;amp;&amp;amp;model&amp;amp;m; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods listing;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods rtf file="C:\SAS\twostep\period&amp;amp;per model&amp;amp;m.rtf" style=journal;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc means data=pe&amp;amp;per&amp;amp;m mean std t probt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; var estimate; class variable;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #00ff00;"&gt;&lt;STRONG&gt;*By variable by variable, it calculates the mean, standard deviation, t-statistics and p-value of the &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #00ff00;"&gt;&lt;STRONG&gt;coefficient estimates;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=pe&amp;amp;per&amp;amp;m; by variable; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods rtf close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%twostep;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2014 22:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161126#M31343</guid>
      <dc:creator>finans_sas</dc:creator>
      <dc:date>2014-05-15T22:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Do Loops, but Single RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161127#M31344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You just need to add the appropriate TITLE statements in the code body. For example just before the Proc Reg or Means something like:&lt;/P&gt;&lt;P&gt;title "This is the title for PER= &amp;amp;Per M= &amp;amp;m";&lt;/P&gt;&lt;P&gt;To create a single RTF or other ODS output file type put all of the output generating code within a single ODS "sandwich".&lt;/P&gt;&lt;P&gt;Since you are running multiple nested loops, probably what you want is to move ODS RTF file = to before the %do Per = loop and have the ODS RTF close after the associated %end. Since the ODS RTF precedes the macor then you'd likely want a fixed file name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2014 23:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161127#M31344</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-15T23:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Do Loops, but Single RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161128#M31345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, ballardw. I followed your suggestions, and the macro ended up generating one single output. However, in the original code that I posted, ODS output is whatever comes out of proc means statement. On the other hand, after the changes that I made, ODS output gives me a output for each permno (regression ids) in addition to the result of proc means operation, which is in hundreds of pages. I am not sure how to go from here. I would deeply appreciate your input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2014 23:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161128#M31345</guid>
      <dc:creator>finans_sas</dc:creator>
      <dc:date>2014-05-15T23:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Do Loops, but Single RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161129#M31346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use NOPRINT in the PROC REG statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 06:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161129#M31346</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-05-16T06:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Do Loops, but Single RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161130#M31347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was afraid that would happen. I generally build all datasets outside of output and then have another loop or call to create the output file..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So take the ODS RTF and the Proc means out side of the current loops you have.&lt;/P&gt;&lt;P&gt;Then add the ODS RTF sandwich around a second loop of similar structure that just runs the proc means part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods rtf file="your name here";&lt;/P&gt;&lt;P&gt; %do per=1 %to 2;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do m=1 %to 2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; title "Output for Per=&amp;amp;per and M=&amp;amp;m";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc means data=pe&amp;amp;per&amp;amp;m mean std t probt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var estimate; class variable;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods rtf close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 14:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161130#M31347</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-16T14:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Do Loops, but Single RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161131#M31348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use of proc document? &lt;A href="https://support.sas.com/documentation/cdl/en/odsug/65308/HTML/default/viewer.htm#n18nmkmj3ed2hrn13i9cwm821blu.htm" title="https://support.sas.com/documentation/cdl/en/odsug/65308/HTML/default/viewer.htm#n18nmkmj3ed2hrn13i9cwm821blu.htm"&gt;SAS(R) 9.3 Output Delivery System: User's Guide, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 18:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Do-Loops-but-Single-RTF/m-p/161131#M31348</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-05-16T18:32:06Z</dc:date>
    </item>
  </channel>
</rss>

