<?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: Truncate .sas string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285372#M58326</link>
    <description>&lt;P&gt;I am still getting the same warning message. It is able to get the filename but not the path. Am I missing something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%unquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; file_path = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%unquote&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;=file_path;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; file_name = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;file_path,-2,.\);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;=file_name;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; path = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%substr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile, 2, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile)-1);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; path = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%substr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;path, 1, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;path) - &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;path, -1, \)));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;=path;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Log:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put %unquote(&amp;amp;_sasprogramfile);&lt;/P&gt;
&lt;P&gt;'T:\egtest1.sas'&lt;/P&gt;
&lt;P&gt;25 %let file_path = %unquote(&amp;amp;_sasprogramfile);&lt;/P&gt;
&lt;P&gt;26 %put &amp;amp;=file_path;&lt;/P&gt;
&lt;P&gt;FILE_PATH='T:\egtest1.sas'&lt;/P&gt;
&lt;P&gt;27 %let file_name = %scan(&amp;amp;file_path,-2,.\);&lt;/P&gt;
&lt;P&gt;28 %put &amp;amp;=file_name;&lt;/P&gt;
&lt;P&gt;FILE_NAME=egtest1&lt;/P&gt;
&lt;P&gt;29&lt;/P&gt;
&lt;P&gt;30&lt;/P&gt;
&lt;P&gt;31&lt;/P&gt;
&lt;P&gt;32 %let path = %substr(&amp;amp;_sasprogramfile, 2, %length(&amp;amp;_sasprogramfile)-1);&lt;/P&gt;
&lt;P&gt;33 %let path = %substr(&amp;amp;path, 1, %length(&amp;amp;path) - %length(%scan(&amp;amp;path, -1, \)));&lt;/P&gt;
&lt;P&gt;34&lt;/P&gt;
&lt;P&gt;35 %put &amp;amp;=path;&lt;/P&gt;
&lt;P&gt;36&lt;/P&gt;
&lt;P&gt;37 GOPTIONS NOACCESSIBLE;&lt;/P&gt;
&lt;P&gt;38 %LET _CLIENTTASKLABEL=;&lt;/P&gt;
&lt;P&gt;39 %LET _CLIENTPROCESSFLOWNAME=;&lt;/P&gt;
&lt;P&gt;40 %LET _CLIENTPROJECTPATH=;&lt;/P&gt;
&lt;P&gt;41 %LET _CLIENTPROJECTNAME=;&lt;/P&gt;
&lt;P&gt;42 %LET _SASPROGRAMFILE=;&lt;/P&gt;
&lt;P&gt;43&lt;/P&gt;
&lt;P&gt;44 ;*';*";*/;quit;run;&lt;/P&gt;
&lt;P&gt;45 ODS _ALL_ CLOSE;&lt;/P&gt;
&lt;P&gt;46&lt;/P&gt;
&lt;P&gt;47&lt;/P&gt;
&lt;P&gt;48 QUIT; RUN;&lt;/P&gt;
&lt;P&gt;49&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2016 20:20:47 GMT</pubDate>
    <dc:creator>KBACHU</dc:creator>
    <dc:date>2016-07-18T20:20:47Z</dc:date>
    <item>
      <title>Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285291#M58287</link>
      <description>&lt;P&gt;I am using the below code to get the filename and filepath for the program I am executing from EG. Is there anyway, I can just get the path without the program name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put %unquote(&amp;amp;_sasprogramfile);&lt;BR /&gt;%let file_path = %unquote(&amp;amp;_sasprogramfile);&lt;BR /&gt;%put &amp;amp;=file_path;&lt;BR /&gt;%let file_name = %scan(&amp;amp;file_path,-2,./);&lt;BR /&gt;%put &amp;amp;=file_name;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="sasSource"&gt;56 %put %unquote(&amp;amp;_sasprogramfile);&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;T:/test/Program10000.sas&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;57 %let file_path = %unquote(&amp;amp;_sasprogramfile);&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;58 %put &amp;amp;=file_path;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;FILE_PATH=T:/test/Program10000.sas&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;59 %let file_name = %scan(&amp;amp;file_path,-2,./);&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;60 %put &amp;amp;=file_name;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;FILE_NAME=Program10000&lt;/DIV&gt;</description>
      <pubDate>Mon, 18 Jul 2016 16:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285291#M58287</guid>
      <dc:creator>KBACHU</dc:creator>
      <dc:date>2016-07-18T16:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285313#M58297</link>
      <description>&lt;P&gt;I think what you are looking to extract is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;T:/test/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's the case, you are heading in the right direction.&amp;nbsp; Here would be a way to approach this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let path = %substr(&amp;amp;program_path, 1, %length(&amp;amp;program_path) - %length(%scan(&amp;amp;program_path, -1, /)));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285313#M58297</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T18:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285342#M58309</link>
      <description>&lt;P&gt;Thank You very much. This is what I am looking for. But when I ran it from EG I am getting the below warning message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Argument 3 to macro function %SUBSTR is out of range&lt;/P&gt;
&lt;P&gt;PATH=&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, 18 Jul 2016 19:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285342#M58309</guid>
      <dc:creator>KBACHU</dc:creator>
      <dc:date>2016-07-18T19:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285345#M58311</link>
      <description>&lt;P&gt;What is the value for &amp;amp;_SASPROGRAMFILE when you run witin EG?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285345#M58311</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T19:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285348#M58313</link>
      <description>&lt;P&gt;%put %unquote(&amp;amp;_sasprogramfile);&lt;/P&gt;
&lt;P&gt;'T:\egtest.sas'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285348#M58313</guid>
      <dc:creator>KBACHU</dc:creator>
      <dc:date>2016-07-18T19:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285354#M58318</link>
      <description>&lt;P&gt;So within EG, your program path has a backwards slash instead of a forward slash.&amp;nbsp; That's easy enough to change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the single quotes really part of the value?&amp;nbsp; Do you want them in the extracted string, or do you just want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;T:\&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285354#M58318</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T20:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285355#M58319</link>
      <description>&lt;P&gt;It should be just T:\ without the quotes&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285355#M58319</guid>
      <dc:creator>KBACHU</dc:creator>
      <dc:date>2016-07-18T20:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285367#M58325</link>
      <description>&lt;P&gt;So safest would be to remove the quotes first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let path = %substr(&amp;amp;_sasprogramfile, 2, %length(&amp;amp;_sasprogramfile)-1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then apply the formula to the new variable using a backward slash:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let path = %substr(&amp;amp;path, 1, %length(&amp;amp;path) - %length(%scan(&amp;amp;path, -1, \)));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you plan on using the code across different operating systems, it is probably safe to include either slash as a delimiter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let path = %substr(&amp;amp;path, 1, %length(&amp;amp;path) - %length(%scan(&amp;amp;path, -1, \/)));&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285367#M58325</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T20:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285372#M58326</link>
      <description>&lt;P&gt;I am still getting the same warning message. It is able to get the filename but not the path. Am I missing something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%unquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; file_path = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%unquote&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;=file_path;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; file_name = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;file_path,-2,.\);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;=file_name;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; path = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%substr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile, 2, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile)-1);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; path = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%substr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;path, 1, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;path) - &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;path, -1, \)));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;=path;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Log:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put %unquote(&amp;amp;_sasprogramfile);&lt;/P&gt;
&lt;P&gt;'T:\egtest1.sas'&lt;/P&gt;
&lt;P&gt;25 %let file_path = %unquote(&amp;amp;_sasprogramfile);&lt;/P&gt;
&lt;P&gt;26 %put &amp;amp;=file_path;&lt;/P&gt;
&lt;P&gt;FILE_PATH='T:\egtest1.sas'&lt;/P&gt;
&lt;P&gt;27 %let file_name = %scan(&amp;amp;file_path,-2,.\);&lt;/P&gt;
&lt;P&gt;28 %put &amp;amp;=file_name;&lt;/P&gt;
&lt;P&gt;FILE_NAME=egtest1&lt;/P&gt;
&lt;P&gt;29&lt;/P&gt;
&lt;P&gt;30&lt;/P&gt;
&lt;P&gt;31&lt;/P&gt;
&lt;P&gt;32 %let path = %substr(&amp;amp;_sasprogramfile, 2, %length(&amp;amp;_sasprogramfile)-1);&lt;/P&gt;
&lt;P&gt;33 %let path = %substr(&amp;amp;path, 1, %length(&amp;amp;path) - %length(%scan(&amp;amp;path, -1, \)));&lt;/P&gt;
&lt;P&gt;34&lt;/P&gt;
&lt;P&gt;35 %put &amp;amp;=path;&lt;/P&gt;
&lt;P&gt;36&lt;/P&gt;
&lt;P&gt;37 GOPTIONS NOACCESSIBLE;&lt;/P&gt;
&lt;P&gt;38 %LET _CLIENTTASKLABEL=;&lt;/P&gt;
&lt;P&gt;39 %LET _CLIENTPROCESSFLOWNAME=;&lt;/P&gt;
&lt;P&gt;40 %LET _CLIENTPROJECTPATH=;&lt;/P&gt;
&lt;P&gt;41 %LET _CLIENTPROJECTNAME=;&lt;/P&gt;
&lt;P&gt;42 %LET _SASPROGRAMFILE=;&lt;/P&gt;
&lt;P&gt;43&lt;/P&gt;
&lt;P&gt;44 ;*';*";*/;quit;run;&lt;/P&gt;
&lt;P&gt;45 ODS _ALL_ CLOSE;&lt;/P&gt;
&lt;P&gt;46&lt;/P&gt;
&lt;P&gt;47&lt;/P&gt;
&lt;P&gt;48 QUIT; RUN;&lt;/P&gt;
&lt;P&gt;49&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285372#M58326</guid>
      <dc:creator>KBACHU</dc:creator>
      <dc:date>2016-07-18T20:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285378#M58328</link>
      <description>&lt;P&gt;You can use the DEQUOTE() function to remove quotes. It will also reverse any doubling of embedded quotes.&lt;/P&gt;
&lt;P&gt;You need to find the file name first.&lt;/P&gt;
&lt;P&gt;Then you can use the length of the name to subset the full prgram path&amp;nbsp;to just the directory name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let file_name=%scan(%qsysfunc(dequote(&amp;amp;_sasprogramfile)),-1,/\);
%let file_path=%substr(%qsysfunc(dequote(&amp;amp;_sasprogramfile)),1,%length(&amp;amp;_sasprogramfile)-%length(&amp;amp;file_name)-2);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let _sasprogramfile='T:\mydir\subdir\egtest.sas';
...
FILE_NAME=egtest.sas FILE_PATH=T:\mydir\subdir\


%let _sasprogramfile='/home/mydir/subdir/egtest.sas';
...
FILE_NAME=egtest.sas FILE_PATH=/home/mydir/subdir/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285378#M58328</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-07-18T20:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285381#M58329</link>
      <description>&lt;P&gt;My fault ... need to subtract 2 instead of 1 to account for both quotes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; path = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%substr&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile, 2, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;_sasprogramfile)-&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="helvetica" size="3"&gt;It wouldn't hurt to add an additional %PUT statement after that, just to check as you go.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285381#M58329</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-18T20:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Truncate .sas string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285443#M58359</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=%sysfunc(prxchange(s/[^\/\\]+$//,-1,%str(&amp;amp;_sasprogramfile)));
%put &amp;amp;path ;&lt;/CODE&gt;&lt;/PRE&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;OUTPUT:&lt;/P&gt;
&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;51&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;52 %let path=%sysfunc(prxchange(s/[^\/\\]+$//,-1,%str(&amp;amp;_sasprogramfile)));&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;53 %put &amp;amp;path ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;/folders/myfolders/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;54&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;55&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;56 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;66&lt;/DIV&gt;</description>
      <pubDate>Tue, 19 Jul 2016 06:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncate-sas-string/m-p/285443#M58359</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-19T06:19:47Z</dc:date>
    </item>
  </channel>
</rss>

