<?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: How to extract characters before a special character from a string variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548669#M74445</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp; Perhaps you could try scan knowing the separator '(' would of course be the first to split the string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $20.;
cards;
48 (500_82)
49 (501_82)
40
;

data want;
set have;
want=scan(id,1,'(');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Apr 2019 22:35:23 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-04-04T22:35:23Z</dc:date>
    <item>
      <title>How to extract characters before a special character from a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548664#M74442</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I have a data set with a bunch of IDs as string variable like eg.below. I want to delete all the characters from "(" and include only the numbers before "(" for each ID. Any help with SAS code is much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;48 (500_82)&lt;/P&gt;&lt;P&gt;49 (501_82)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;P&gt;ID_New&lt;/P&gt;&lt;P&gt;48&lt;/P&gt;&lt;P&gt;49&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 22:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548664#M74442</guid>
      <dc:creator>sms1891</dc:creator>
      <dc:date>2019-04-04T22:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract characters before a special character from a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548666#M74443</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $20.;
infile datalines dlm='';
datalines;
48 (500_82)
49 (501_82)
;

data want;
   set have;
   ID_New=substr(ID, 1, find(ID, '(')-1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 22:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548666#M74443</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-04-04T22:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract characters before a special character from a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548667#M74444</link>
      <description>&lt;P&gt;If your pattern is not so consistent with some records &lt;STRONG&gt;not&lt;/STRONG&gt; having the special character like the 3rd in the modified sample, the following should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $20.;
cards;
48 (500_82)
49 (501_82)
40
;

data want;
set have;
if find(id,'(')&amp;gt;0 then want=substr(id,1,find(id,'(')-1);
else want=id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 22:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548667#M74444</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-04T22:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract characters before a special character from a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548669#M74445</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146852"&gt;@sms1891&lt;/a&gt;&amp;nbsp; Perhaps you could try scan knowing the separator '(' would of course be the first to split the string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $20.;
cards;
48 (500_82)
49 (501_82)
40
;

data want;
set have;
want=scan(id,1,'(');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 22:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/548669#M74445</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-04T22:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract characters before a special character from a string variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/761615#M80909</link>
      <description>data one;&lt;BR /&gt;set have;&lt;BR /&gt;string1=substr(id,1,2);&lt;BR /&gt;run;</description>
      <pubDate>Sat, 14 Aug 2021 21:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-extract-characters-before-a-special-character-from-a/m-p/761615#M80909</guid>
      <dc:creator>anamika1_</dc:creator>
      <dc:date>2021-08-14T21:18:01Z</dc:date>
    </item>
  </channel>
</rss>

