<?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: Using program name as ods rtf file name: Revisited in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415275#M101821</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your post (and sorry not to respond to your post sooner).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I replace&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods rtf file="&amp;amp;fname.";&lt;/PRE&gt;&lt;P&gt;with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods rtf file="&amp;amp;fname.rtf.";&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;A file 'temp.sasrtf' was created.&amp;nbsp; This is my result file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the program name is 'temp.sas'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked somehow even though extension looks strange!&amp;nbsp; I wish I could just have 'temp.rtf'....&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2017 18:26:46 GMT</pubDate>
    <dc:creator>Yoko</dc:creator>
    <dc:date>2017-11-21T18:26:46Z</dc:date>
    <item>
      <title>Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/413689#M101281</link>
      <description>&lt;P&gt;When I asked a question about saving an rtf file using program name (&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410319#M100265" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410319#M100265&lt;/A&gt;), I thought I found a solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
  tmp="%sysfunc(GetOption(SYSIN))";
  call symput('fname',scan(tmp,2,"]"));
run;

ods rtf file="&amp;amp;fname.";
...&lt;/PRE&gt;&lt;P&gt;But, later, I found that this program replaced the content of the current program with results in an rtf format.&amp;nbsp; That is, when I click my program (e.g., my_program.sas),&amp;nbsp;it opens as a rtf file of the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to run my program (e.g., my_program.sas) and automatically create a result file as my_program.rtf without typing 'my_program'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;(I'll check the program and results more carefully this time!)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 15:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/413689#M101281</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-11-15T15:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/413700#M101284</link>
      <description>&lt;P&gt;Perhaps you need to examine the value that &amp;amp;fname has and then replace the likely .SAS extension with .RTF .&lt;/P&gt;
&lt;P&gt;This would most likely be easiest in the data _null_ step by modifying the TMP variable prior to the Call Symput. You may want to consider using call symputx as well. Symputx strips some blank characters that occasionally may cause problems.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 15:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/413700#M101284</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-15T15:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415275#M101821</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your post (and sorry not to respond to your post sooner).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I replace&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods rtf file="&amp;amp;fname.";&lt;/PRE&gt;&lt;P&gt;with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods rtf file="&amp;amp;fname.rtf.";&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;A file 'temp.sasrtf' was created.&amp;nbsp; This is my result file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the program name is 'temp.sas'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked somehow even though extension looks strange!&amp;nbsp; I wish I could just have 'temp.rtf'....&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 18:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415275#M101821</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-11-21T18:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415303#M101828</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152732"&gt;@Yoko&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your post (and sorry not to respond to your post sooner).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I replace&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods rtf file="&amp;amp;fname.";&lt;/PRE&gt;
&lt;P&gt;with&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods rtf file="&amp;amp;fname.rtf.";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;A file 'temp.sasrtf' was created.&amp;nbsp; This is my result file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, the program name is 'temp.sas'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It worked somehow even though extension looks strange!&amp;nbsp; I wish I could just have 'temp.rtf'....&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yoko&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The reason the file was created with an extension of 'sasrtf' instead of 'sas.rtf' is that the SAS macro processor used the period after &amp;amp;FNAME as an indication of where the name of the macro variable ended. Without the period SAS would look for a macro variable named FNAMERTF.&amp;nbsp; So if you want to get an actual period in front of rtf you need to have two of them. One to mark the end of the macro variable reference and the other to become part of the file name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods rtf file="&amp;amp;fname..rtf.";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 20:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415303#M101828</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-21T20:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415304#M101829</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried:&amp;nbsp;ods rtf file="&amp;amp;fname..rtf.";&lt;/P&gt;&lt;P&gt;And I got this error message:&amp;nbsp;&amp;nbsp;ERROR: Invalid open mode.&lt;/P&gt;&lt;P&gt;An rtf file was not created.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Strangely, the program went through without an obvious error message, but when I checked the log, I found errors..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 20:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415304#M101829</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-11-21T20:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415308#M101830</link>
      <description>&lt;P&gt;Where did you get that message?&lt;/P&gt;
&lt;P&gt;Are you trying to write a directory that is read only?&amp;nbsp; Or that already has a file with that name that you cannot delete or overwrite?&lt;/P&gt;
&lt;P&gt;Are you running some interactive environment like&amp;nbsp;SAS Display Manger that might try to let you preview RTF files that you created?&amp;nbsp; If so then perhaps it is too dumb to know what to do with a file with two periods in its name?&amp;nbsp; 'test.sas.rtf'&amp;nbsp; That is why I normally try to replace the .sas with the new extension rather than just appending '.rtf'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way to test is to run it once with the filename you use hardcoded and see if you can create the error or fix it by using different filenames.&amp;nbsp; Once you know what works then adjust your code to handle it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some simple code that will take value of macro variable FNAME and replace '.sas' suffix with '.rtf' suffix.&amp;nbsp; If there is no '.sas' suffix then it just adds the '.rtf' to the end.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  length fname $300;
  fname=symget('fname');
  if upcase(scan(fname,-1,'.'))='SAS' then fname=substr(fname,1,length(fname)-4);
  fname =cats(fname,'.rtf');
  call symputx('fname',fname);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 20:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/415308#M101830</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-21T20:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name: Revisited</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/416444#M102246</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Sorry for not replying to you sooner)&lt;/P&gt;&lt;P&gt;I got the message 'ERROR: Invalid open mode' right after this line: ods rtf file="&amp;amp;fname..rtf.";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your code you posted last time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did not get any error or warning messages.&amp;nbsp; But, after the code, I saw this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function symget at linne...&lt;/P&gt;&lt;P&gt;fname = .rtf _ERROR_=1 _N_=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 15:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name-Revisited/m-p/416444#M102246</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-11-27T15:54:51Z</dc:date>
    </item>
  </channel>
</rss>

