<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410253#M100259</link>
    <description>&lt;P&gt;I really don't think that is your best option, the code will not work if run in batch for instance.&amp;nbsp; However you could change your code to make it work for now:&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;What I am doing here is putting the macro data into a datastep and using nice simple base SAS commands to process the data (for that is what Base SAS is for) to process the string, pull out the bit I want and then send back to macro.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2017 14:46:08 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-03T14:46:08Z</dc:date>
    <item>
      <title>Using program name as ods rtf file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410249#M100258</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use this program to obtain path and file name:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let execpath=" ";&lt;BR /&gt;&lt;BR /&gt;%macro setexecpath;&lt;BR /&gt;%let execpath=%sysfunc(GetOption(SYSIN));&lt;BR /&gt;%if %length(&amp;amp;execpath)=0&lt;BR /&gt;%then %let execpath=%sysget(SAS_EXECFILEPATH);&lt;BR /&gt;%mend setexecpath;&lt;BR /&gt;&lt;BR /&gt;%setexecpath;&lt;BR /&gt;%put &amp;amp;execpath;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;XX$XX:[XX.myfolder.program]program_name.SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just want to use a portion of the result like 'program_name' instead of typing the program name as a rtf file name each time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this, thinking that I would have a long file name:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods rtf file="%sysfunc(getoption(SYSIN)).rtf";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I got an error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Invalid open mod&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not need the full information to start with, but could anybody tell me what I should write after 'ods rtf file=' to get just a program_name?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&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;</description>
      <pubDate>Fri, 03 Nov 2017 14:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410249#M100258</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-11-03T14:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410253#M100259</link>
      <description>&lt;P&gt;I really don't think that is your best option, the code will not work if run in batch for instance.&amp;nbsp; However you could change your code to make it work for now:&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;What I am doing here is putting the macro data into a datastep and using nice simple base SAS commands to process the data (for that is what Base SAS is for) to process the string, pull out the bit I want and then send back to macro.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 14:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410253#M100259</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-03T14:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410311#M100264</link>
      <description>&lt;P&gt;Thank you, it worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 16:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410311#M100264</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2017-11-03T16:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using program name as ods rtf file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410319#M100265</link>
      <description>&lt;P&gt;Are you working on a windows system, using the Enhanced editor (which implies running in Display Manager)?&lt;/P&gt;
&lt;P&gt;If not the SAS_EXECFILEPATH isn't available.&lt;/P&gt;
&lt;P&gt;If you are the value isn't set until after you save the program file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And to get just the path if the above conditions are met (and assuming you don't put periods in the middle of your paths, of so...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; execpath= &lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%scan&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%sysget&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(SAS_EXECFILEPATH),1,.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; &amp;amp;execpath; (if you want to see the resolved version)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;ods rtf file="&amp;amp;execpath..rtf"; should then work.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 16:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-program-name-as-ods-rtf-file-name/m-p/410319#M100265</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-03T16:16:59Z</dc:date>
    </item>
  </channel>
</rss>

