<?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: EXtracting characters from back.. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/373027#M89228</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130581"&gt;@Bhargav_Movva&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I think scan function is not correct in this case,if &amp;nbsp;you see the data,in some records CAP/CAPSULE/TAB/TABLET are a not separately mentioned.I mean tab and cap are not separated as words.As per my knpwledge is concerned scan works on word basis.Hence here substr is perfect&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I depends on what you are trying to do. Your example string will scan into words using the default delimiters. You can use other delimiters with the scan() function.&lt;/P&gt;
&lt;PRE&gt;205  data _null_;
206    str='CAP/CAPSULE/TAB/TABLET';
207    lastword=scan(str,-1);
208    put (str lastword) (=);
209  run;

str=CAP/CAPSULE/TAB/TABLET lastword=TABLET
&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Jul 2017 14:54:57 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-07-04T14:54:57Z</dc:date>
    <item>
      <title>EXtracting characters from back..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372383#M89040</link>
      <description>&lt;P&gt;My data looks like this..&lt;/P&gt;&lt;P&gt;LIMCEE TABLET&lt;BR /&gt;CELINTABLET&lt;BR /&gt;AMOXYCLAV CAP&lt;BR /&gt;RECLIMET OD TAB&lt;BR /&gt;GLYCOMET SR TAB&lt;BR /&gt;REFRESH TEARS&lt;BR /&gt;WELL WOMEN CAPSULE&lt;BR /&gt;RENERVECAPSULE&lt;BR /&gt;MET XL TABLET&lt;BR /&gt;MET XL AM TABLET&lt;BR /&gt;SHELCAL&lt;BR /&gt;SHELCAL HD&lt;BR /&gt;SHELCAL HD12&lt;BR /&gt;TENCLIMET TABLET&lt;BR /&gt;ZITAMET PLUS TABLET&lt;BR /&gt;PREGAB M CAP&lt;BR /&gt;LOSAR H40 TABLET&lt;BR /&gt;LOSAR H80 TAB&lt;BR /&gt;PRAZOPRESS XL 25 TABLET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create separate dataset for names ending with TAB and TABLET as TAB_INFO &amp;nbsp;and&lt;/P&gt;&lt;P&gt;names ending with CAP and CAPSULES as CAP_INFO.Tried something with substr and substrn..but nothing worked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 06:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372383#M89040</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2017-07-01T06:36:23Z</dc:date>
    </item>
    <item>
      <title>EXTRACTING characters from back</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372385#M89043</link>
      <description>&lt;P&gt;My data looks like this..&lt;/P&gt;&lt;P&gt;LIMCEE TABLET&lt;BR /&gt;CELINTABLET&lt;BR /&gt;AMOXYCLAV CAP&lt;BR /&gt;RECLIMET OD TAB&lt;BR /&gt;GLYCOMET SR TAB&lt;BR /&gt;REFRESH TEARS&lt;BR /&gt;WELL WOMEN CAPSULE&lt;BR /&gt;RENERVECAPSULE&lt;BR /&gt;MET XL TABLET&lt;BR /&gt;MET XL AM TABLET&lt;BR /&gt;SHELCAL&lt;BR /&gt;SHELCAL HD&lt;BR /&gt;SHELCAL HD12&lt;BR /&gt;TENCLIMET TABLET&lt;BR /&gt;ZITAMET PLUS TABLET&lt;BR /&gt;PREGAB M CAP&lt;BR /&gt;LOSAR H40 TABLET&lt;BR /&gt;LOSAR H80 TAB&lt;BR /&gt;PRAZOPRESS XL 25 TABLET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create separate dataset for names ending with TAB and TABLET as TAB_INFO &amp;nbsp;and&lt;/P&gt;&lt;P&gt;names ending with CAP and CAPSULES as CAP_INFO.Tried something with substr and substrn..but nothing worked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 06:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372385#M89043</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2017-07-01T06:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: EXTRACTING characters from back</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372396#M89047</link>
      <description>&lt;P&gt;maybe something like this? &lt;A href="http://support.sas.com/publishing/pubcat/chaps/59343.pdf" target="_self"&gt;Character Functions &lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string $35.;
datalines;
LIMCEE TABLET
CELINTABLET
AMOXYCLAV CAP
RECLIMET OD TAB
GLYCOMET SR TAB
REFRESH TEARS
WELL WOMEN CAPSULE
RENERVECAPSULE
MET XL TABLET
MET XL AM TABLET
SHELCAL
SHELCAL HD
SHELCAL HD12
TENCLIMET TABLET
ZITAMET PLUS TABLET
PREGAB M CAP
LOSAR H40 TABLET
LOSAR H80 TAB
PRAZOPRESS XL 25 TABLET
;
run;

data TAB_INFO CAP_INFO OTHERS; 
	set have;
	if substr(upcase(string),length(string)-5)='TABLET' or substr(upcase(string),length(string)-2)='TAB' then output TAB_INFO;
		else if substr(upcase(string),length(string)-6)='CAPSULE' or substr(upcase(string),length(string)-2)='CAP' then output CAP_INFO;
			else output OTHERS;
run; 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 08:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372396#M89047</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2017-07-01T08:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: EXTRACTING characters from back</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372403#M89049</link>
      <description>&lt;P&gt;Hey thanks !!!! Wong it worked.But can you try with substrr(right of) function??&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 09:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372403#M89049</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2017-07-01T09:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: EXTRACTING characters from back</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372411#M89050</link>
      <description>&lt;P&gt;That does use substr (right of) function. In this case the = is merely a substitute for eq and performs the right of action.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 13:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372411#M89050</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-01T13:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: EXtracting characters from back..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372621#M89125</link>
      <description>&lt;P&gt;Looks like something that it easy to handle with SCAN() function. You can use negative index to scan from the right instead of left.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TAB_INFO CAP_INFO;
  set have ;
  if scan(MYVAR,-1) in ('TAB','TABLET') then output TAB_INFO;
  else if scan(MYVAR,-1) in ('CAP','CAPSULES') then output CAP_INFO;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps even better you can use the SELECT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TAB_INFO CAP_INFO;
  set have ;
  select (scan(MYVAR,-1));
    when ('TAB','TABLET') output TAB_INFO;
    when ('CAP','CAPSULES') output CAP_INFO;
    otherwise;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 20:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372621#M89125</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-02T20:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: EXtracting characters from back..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372909#M89191</link>
      <description>&lt;P&gt;I think scan function is not correct in this case,if &amp;nbsp;you see the data,in some records CAP/CAPSULE/TAB/TABLET are a not separately mentioned.I mean tab and cap are not separated as words.As per my knpwledge is concerned scan works on word basis.Hence here substr is perfect&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 03:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372909#M89191</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2017-07-04T03:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: EXtracting characters from back..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372922#M89195</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;input product_name$40.;&lt;BR /&gt;datalines;&lt;BR /&gt;LIMCEE TABLET&lt;BR /&gt;CELINTABLET&lt;BR /&gt;AMOXYCLAV CAP&lt;BR /&gt;RECLIMET OD TAB&lt;BR /&gt;GLYCOMET SR TAB&lt;BR /&gt;REFRESH TEARS&lt;BR /&gt;WELL WOMEN CAPSULE&lt;BR /&gt;RENERVECAPSULE&lt;BR /&gt;MET XL TABLET&lt;BR /&gt;MET XL AM TABLET&lt;BR /&gt;SHELCAL&lt;BR /&gt;SHELCAL HD&lt;BR /&gt;SHELCAL HD12&lt;BR /&gt;TENCLIMET TABLET&lt;BR /&gt;ZITAMET PLUS TABLET&lt;BR /&gt;PREGAB M CAP&lt;BR /&gt;LOSAR H40 TABLET&lt;BR /&gt;LOSAR H80 TAB&lt;BR /&gt;PRAZOPRESS XL 25 TABLET&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;if index(product_name,"TABLET") then Remark = 'INFO_TAB';&lt;BR /&gt;else if index(product_name,"TAB") then Remark = 'INFO_TAB';&lt;BR /&gt;else if index(product_name,"CAP") then Remark = 'INFO_CAP';&lt;BR /&gt;else if index(product_name,"CAPSULE") then Remark = 'INFO_CAP';&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 06:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/372922#M89195</guid>
      <dc:creator>TarunKumar</dc:creator>
      <dc:date>2017-07-04T06:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: EXtracting characters from back..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/373027#M89228</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130581"&gt;@Bhargav_Movva&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I think scan function is not correct in this case,if &amp;nbsp;you see the data,in some records CAP/CAPSULE/TAB/TABLET are a not separately mentioned.I mean tab and cap are not separated as words.As per my knpwledge is concerned scan works on word basis.Hence here substr is perfect&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I depends on what you are trying to do. Your example string will scan into words using the default delimiters. You can use other delimiters with the scan() function.&lt;/P&gt;
&lt;PRE&gt;205  data _null_;
206    str='CAP/CAPSULE/TAB/TABLET';
207    lastword=scan(str,-1);
208    put (str lastword) (=);
209  run;

str=CAP/CAPSULE/TAB/TABLET lastword=TABLET
&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jul 2017 14:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EXtracting-characters-from-back/m-p/373027#M89228</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-04T14:54:57Z</dc:date>
    </item>
  </channel>
</rss>

