<?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 function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391658#M94126</link>
    <description>&lt;P&gt;the files will have many variations not just limited to&amp;nbsp;&lt;SPAN&gt;scores.rpt or _scores_income.rpt.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Aug 2017 20:14:04 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2017-08-29T20:14:04Z</dc:date>
    <item>
      <title>string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391637#M94116</link>
      <description>&lt;P&gt;How to achieve this?&lt;/P&gt;&lt;P&gt;if a varaible has values&lt;BR /&gt;finance_data_scores_income.rpt&lt;BR /&gt;finace_scores.rpt&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;the desired output is (to remove _scores_income.rpt and _scores.rpt)&lt;BR /&gt;finance_data&lt;BR /&gt;finance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 19:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391637#M94116</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-08-29T19:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391642#M94118</link>
      <description>&lt;P&gt;Are those the only ones or does this need to be generalized?&lt;/P&gt;
&lt;P&gt;If only those words, look at TRANWRD() function to replace/remove the text.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 19:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391642#M94118</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T19:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391646#M94120</link>
      <description>&lt;P&gt;There are more than one way to achieve it, assuming that TEXT_IN is the variable which contains the string to check:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) result = substr(text_in, 1, find(text_in,'_scores'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) if text_in = '&lt;SPAN&gt;finance_data_scores_income.rpt' then result = 'finance_data'; else&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; if text_in = '&lt;/SPAN&gt;finace_scores.rpt' &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; then result = '&lt;SPAN&gt;finance';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3) text1 =&amp;nbsp;'finance_data_scores_income.rpt';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; text2 =&amp;nbsp;'finace_scores.rpt';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; length1 = length(text1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; length2 = length(text2);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;lengthx = length(text_in);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;select (lengthx);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; when (length1) result =&amp;nbsp;'finance_data';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; when (length2) result =&amp;nbsp;&amp;nbsp;'finance';;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 19:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391646#M94120</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-29T19:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391649#M94121</link>
      <description>&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; have;&lt;/P&gt;&lt;P&gt;input var $50.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;finance_data_scores_income.rpt&lt;/P&gt;&lt;P&gt;finance_scores.rpt&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;k= index(var,'_scores.rpt');&lt;/P&gt;&lt;P&gt;if k&amp;gt;&lt;STRONG&gt;0&lt;/STRONG&gt; then substr(var,k)=' ';&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;k=index(var,'_scores_income.rpt');&lt;/P&gt;&lt;P&gt;if k&amp;gt;&lt;STRONG&gt;0&lt;/STRONG&gt; then substr(var,k)=' ';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop k;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 19:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391649#M94121</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-29T19:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391658#M94126</link>
      <description>&lt;P&gt;the files will have many variations not just limited to&amp;nbsp;&lt;SPAN&gt;scores.rpt or _scores_income.rpt.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 20:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391658#M94126</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-08-29T20:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391662#M94127</link>
      <description>Then you need to provide a better sample data set that reflects your actual situation.</description>
      <pubDate>Tue, 29 Aug 2017 20:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391662#M94127</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-29T20:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391807#M94184</link>
      <description>&lt;PRE&gt;

data have;
input x $40.;
want=prxchange('s/_scores[_a-z]*\.rpt//i',-1,x);
cards;
finance_data_scores_income.rpt
finace_scores.rpt
;
run;


&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Aug 2017 12:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391807#M94184</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-08-30T12:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391896#M94214</link>
      <description>&lt;P&gt;Thanks KSharp, I tried to improvise the code by passing a macro variable in place of _scores instead and it failed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want=prxchange("s/_&amp;amp;name.[_a-z]*\.rpt//i",-1,x);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8&amp;nbsp; !&amp;nbsp; array charvar&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 15:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/391896#M94214</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-08-30T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: string function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/392169#M94326</link>
      <description>&lt;P&gt;You could try this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let name=scores;
data have;
input x $40.;
pid=cats('s/_',"&amp;amp;name",'[_a-z]*\.rpt//i');
want=prxchange(pid,-1,x);
cards;
finance_data_scores_income.rpt
finace_scores.rpt
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2017 12:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-function/m-p/392169#M94326</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-08-31T12:27:49Z</dc:date>
    </item>
  </channel>
</rss>

