<?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: String manipulation in SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55859#M15604</link>
    <description>In a possibly completely warped approach if all of the files are 1) SAS data sets and 2) in the same folder I would be tempted to assign a library name to the folder and then use the SAS dictionary.members table to get the names.</description>
    <pubDate>Tue, 21 Jul 2009 22:32:31 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2009-07-21T22:32:31Z</dc:date>
    <item>
      <title>String manipulation in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55854#M15599</link>
      <description>I wanted some help to get some string manipulation functions working in my SAS program.&lt;BR /&gt;
&lt;BR /&gt;
I have a data set which has a column called file with the absolute path of SAS dataset files in a particular specified location on File System. The data set looks something like..&lt;BR /&gt;
&lt;BR /&gt;
file&lt;BR /&gt;
----------------------&lt;BR /&gt;
C:\MySAS\MyData\Folder1\unit1.sas7bdat&lt;BR /&gt;
C:\MySAS\Folder2\unit2.sas7bdat&lt;BR /&gt;
C:\MySAS\Folder3\unit3.sas7bdat&lt;BR /&gt;
&lt;BR /&gt;
...&lt;BR /&gt;
..&lt;BR /&gt;
&lt;BR /&gt;
And so on&lt;BR /&gt;
&lt;BR /&gt;
What I want to do is, for each entry in the dataset I want to get the dataset name&lt;BR /&gt;
In the above example, for first entry C:\MySAS\MyData\Folder1\unit1.sas7bdat&lt;BR /&gt;
I want to get "unit1.sas7bdat" string extracted.&lt;BR /&gt;
&lt;BR /&gt;
I tried to use the index function..INDEX(file,'\');&lt;BR /&gt;
&lt;BR /&gt;
but don't know how to use it recursively to get till the last slash. After getting the index of last '\' I thouguht I can use substring to get the part of string from that index onwards.&lt;BR /&gt;
&lt;BR /&gt;
[BTW, is there any function that returns the index of last occurence of a character in string..like in Java there lastindexof(String,character)]&lt;BR /&gt;
&lt;BR /&gt;
Any pointers , help on this?&lt;BR /&gt;
&lt;BR /&gt;
Any help much appreciated!&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Neelam</description>
      <pubDate>Fri, 17 Jul 2009 18:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55854#M15599</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-17T18:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55855#M15600</link>
      <description>Explore using the FIND function with a minus third argument to start search from the end.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 17 Jul 2009 18:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55855#M15600</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-17T18:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55856#M15601</link>
      <description>If you are not sure that it is always the third argument, you could use the reverse function and use the index function to find the first "word" (delimited by \) and then reverse back.&lt;BR /&gt;
&lt;BR /&gt;
ie   last_file_name = reverse(scan(reverse(pathname),1,'\'));</description>
      <pubDate>Fri, 17 Jul 2009 18:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55856#M15601</guid>
      <dc:creator>LAP</dc:creator>
      <dc:date>2009-07-17T18:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55857#M15602</link>
      <description>Thank you Scott and LAP. You were of great help!&lt;BR /&gt;
&lt;BR /&gt;
Both options worked for me ..I tried&lt;BR /&gt;
&lt;BR /&gt;
index = FIND(file,'\',"i",-99);&lt;BR /&gt;
datasetName = SUBSTR(file,index+1);&lt;BR /&gt;
&lt;BR /&gt;
and&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
datasetName = reverse(scan(reverse(file),1,'\'));</description>
      <pubDate>Fri, 17 Jul 2009 18:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55857#M15602</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-17T18:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55858#M15603</link>
      <description>the scan function can simplify this[pre]   file = scan( pafthfile, -1, '/\' ) ;[/pre]&lt;BR /&gt;
try that&lt;BR /&gt;
 &lt;BR /&gt;
Peterc</description>
      <pubDate>Sun, 19 Jul 2009 19:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55858#M15603</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-07-19T19:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: String manipulation in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55859#M15604</link>
      <description>In a possibly completely warped approach if all of the files are 1) SAS data sets and 2) in the same folder I would be tempted to assign a library name to the folder and then use the SAS dictionary.members table to get the names.</description>
      <pubDate>Tue, 21 Jul 2009 22:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-manipulation-in-SAS/m-p/55859#M15604</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2009-07-21T22:32:31Z</dc:date>
    </item>
  </channel>
</rss>

