<?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 remove unwanted characters and the values after the characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308201#M66106</link>
    <description>&lt;P&gt;I'd try the tranwrd() function, and then scan():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input term $100.;
cards;
Subject did not drink 50% of the meal!! Chicken
;
run;

data want;
set have;
term = tranwrd(term,"!!","|");
term = scan(term,1,"|");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Since one can only use single characters as delimiters in scan().&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2016 07:19:04 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-10-31T07:19:04Z</dc:date>
    <item>
      <title>How to remove unwanted characters and the values after those characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308192#M66102</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;In my data some values contain "!!" characters in the middle of values. I need to remove the characters and the values after the characters. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data&lt;/P&gt;&lt;P&gt;term&lt;/P&gt;&lt;P&gt;Subject did not drink 50% of the meal!! Chicken&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Subject did not drink 50% of the meal&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 05:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308192#M66102</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-10-31T05:35:44Z</dc:date>
    </item>
    <item>
      <title>how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308193#M66105</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;In my data some values contain "!!" characters in the middle of values. I need to remove the characters and the values after the characters. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data&lt;/P&gt;&lt;P&gt;term&lt;/P&gt;&lt;P&gt;Subject did not drink 50% of the meal!! Chicken&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Subject did not drink 50% of the meal&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 05:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308193#M66105</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-10-31T05:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove unwanted characters and the values after those characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308195#M66104</link>
      <description>&lt;P&gt;Scan function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 06:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308195#M66104</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-31T06:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308201#M66106</link>
      <description>&lt;P&gt;I'd try the tranwrd() function, and then scan():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input term $100.;
cards;
Subject did not drink 50% of the meal!! Chicken
;
run;

data want;
set have;
term = tranwrd(term,"!!","|");
term = scan(term,1,"|");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Since one can only use single characters as delimiters in scan().&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 07:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308201#M66106</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-31T07:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308202#M66107</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
string='Subject did not drink 50% of the meal!! Chicken';
newstring = substr( string,1,index(string,'!!') - 1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2016 07:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308202#M66107</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-10-31T07:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove unwanted characters and the values after those characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308219#M66113</link>
      <description>&lt;P&gt;Sounds like a job for the compress function - which removes given characters:&lt;/P&gt;
&lt;PRE&gt;data have;
  infile cards truncover;
  input term $100.;
  term2=compress(term,"!");
cards;
Subject did not drink 50% of the meal!! Chicken
;
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2016 09:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308219#M66113</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-31T09:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308223#M66114</link>
      <description>&lt;P&gt;If you just want everything before the first exclamation mark then the scan() function on its own&amp;nbsp;should do.&lt;/P&gt;
&lt;P&gt;Not sure why&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;&amp;nbsp;believes that duplicates need replacement for your use case.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  input term $100.;
  cards;
Subject did not drink 50% of the meal!! Chicken
;
run;

data want;
  set have;
  term = scan(term,1,"!");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2016 09:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308223#M66114</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-31T09:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308246#M66119</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;Not sure why&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;believes that duplicates need replacement for your use case.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, if you have a single exclamation mark in the text before the doubles ...&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 11:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308246#M66119</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-31T11:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308729#M66285</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;But didn't the OP tell us that he just wants "everything" from the beginning up to the first exclamation mark? So what do we care about any futher exclamation marks in the string. Based on your code I must be missing something.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 11:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308729#M66285</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-02T11:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308736#M66290</link>
      <description>&lt;P&gt;Look at the log from this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
term = 'Subject complains! Subject did not drink 50% of the meal!! Chicken';
term1 = tranwrd(term,"!!","|");
term1 = scan(term,1,"|");
term2 = scan(term,1,"!");
put term1=;
put term2=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The OP stated that the delimiter is a sequence of two exclamation marks.&lt;/P&gt;
&lt;P&gt;Granted that I may be a little overcautious here, but better safe than sorry.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 12:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308736#M66290</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-02T12:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove unwanted characters and the values after the characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308963#M66390</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Thanks. I did miss that the delimiter is TWO pipes. That explains what your'e doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here a variant using RegEx&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  term = 'Subject complains!! Subject did not drink 50% of the meal!! Chicken';
  output;
  term = 'Subject complains! Subject did not drink 50% of the meal!! Chicken';
  output;
  term = 'something';
  output;
run;

data want;
  set have;
  if 0 then want_str=term;
  want_str=prxchange('s/(!{2}.*)//oi',1,term);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 09:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-characters-and-the-values-after-those/m-p/308963#M66390</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-03T09:52:54Z</dc:date>
    </item>
  </channel>
</rss>

