<?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 clean a character variable from some standardised character chains? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589942#M14968</link>
    <description>&lt;P&gt;Thank you for your answers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2019 07:27:52 GMT</pubDate>
    <dc:creator>PierreYvesILY</dc:creator>
    <dc:date>2019-09-19T07:27:52Z</dc:date>
    <item>
      <title>How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589576#M14915</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to work on data that are not properly registered in the database. One of the variables is a Name (character, $35.) but in many cases it is completed by error : ' und' or ' oder' are added ton the names (empty space as first part of the character chain).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Namen ;&lt;BR /&gt;format Name $35.;&lt;BR /&gt;input Name &amp;amp;;&lt;BR /&gt;datalines;&lt;BR /&gt;Name1 und&lt;BR /&gt;Name2 und&lt;BR /&gt;Name3 und&lt;BR /&gt;Name4 oder&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to clean the Variable Name from all ' und' and ' oder' and get a datastep where only the names are present:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name1&lt;/P&gt;&lt;P&gt;Name2&lt;BR /&gt;Name3&lt;BR /&gt;Name4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I proceed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 10:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589576#M14915</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2019-09-18T10:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589581#M14916</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Namen ;
input Name &amp;amp;$35.;
position=prxmatch('m/und|oder/i',strip(name));
name2=substr(strip(name),1,position-1);
datalines;
Name1 und
Name2 und
Name3 und
Name4 oder
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Sep 2019 10:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589581#M14916</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-18T10:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589583#M14917</link>
      <description>&lt;P&gt;Alternatively with scan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Namen ;
input Name &amp;amp;$35.;
name2=scan(strip(name),1,' ');
datalines;
Name1 und
Name2 und
Name3 und
Name4 oder
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Sep 2019 10:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589583#M14917</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-18T10:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589645#M14920</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks, I tested the second solution first, and come to the problem that some of the NAME observations also contains blank spaces. For instance:&lt;/P&gt;&lt;P&gt;Name1 = 'Von und Zu' and the original NAME content is 'Von und Zu und'&lt;/P&gt;&lt;P&gt;Name2 = 'Tortilla'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and the original NAME content is 'Tortilla und'&lt;/P&gt;&lt;P&gt;Name3 = 'Bin dahoam' and the original NAME content is Bin dahoam und'&lt;/P&gt;&lt;P&gt;Name4 = 'Curry Wurst' and the original NAME content is 'Curry Wurst und'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to get the list of Name1 to Name4 from the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; Namen &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Name &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;35&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
name2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;strip&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;Von und Zu und
Tortilla und
Bin dahoam und
Curry Wurst und&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 13:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589645#M14920</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2019-09-18T13:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589657#M14923</link>
      <description>&lt;P&gt;Hope this code will help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Namen ;
input Name &amp;amp;$35.;
name2=prxchange('s/und//i',-1,name);
datalines;
Von und Zu und
Tortilla und
Bin dahoam und
Curry Wurst und
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Sep 2019 14:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589657#M14923</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-18T14:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589705#M14929</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the answer is practicable but I need to test with the real data tomorrow.&lt;/P&gt;&lt;P&gt;Anyway, this code simplifies the further treatment a lot, and then I will only have to focus on the exceptions like ‘Von und Zu’ where the Name in itself contains the ‘ und’.&lt;/P&gt;&lt;P&gt;Nevertheless, I don’t understand what each parameter of the function does and have to research this:&lt;/P&gt;&lt;P&gt;name2=prxchange('s/und//i',-1,name);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is the meaning of the s, the /, the //, the i and the -1.&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 15:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589705#M14929</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2019-09-18T15:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589712#M14933</link>
      <description>&lt;P&gt;Probably easier to understand if you first just check if the last word is one you want to remove.&amp;nbsp; And then remove it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  last_word = scan(name,-1,' ');
  if last_word in ('und','oder') then name=substrn(name,1,length(name)-length(last_word));
  drop last_word;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Sep 2019 15:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589712#M14933</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-18T15:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589919#M14962</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I think the answer is practicable but I need to test with the real data tomorrow.&lt;BR /&gt;Anyway, this code simplifies the further treatment a lot, and then I will only have to focus on the exceptions like 'Von und Zu' where the Name in itself contains the ' und'.&lt;BR /&gt;Nevertheless, I don't understand what each parameter of the function does and have to research this:&lt;BR /&gt;&lt;BR /&gt;name2=prxchange('s/und//i',-1,name);&lt;BR /&gt;&lt;BR /&gt;what is the meaning of the s, the /, the //, the i and the -1.&lt;BR /&gt;Thanks a lot&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Sep 2019 05:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589919#M14962</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2019-09-19T05:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589942#M14968</link>
      <description>&lt;P&gt;Thank you for your answers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 07:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589942#M14968</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2019-09-19T07:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589961#M14973</link>
      <description>Sure, please test and let me know. &lt;BR /&gt;s - represents substitution &lt;BR /&gt;/ / /- these are delimiters so anything inbetween these delimiters is checked and the third / represent anything between the second / and third / will be replaced with.  &lt;BR /&gt;-1 - it tells the number of times to replace here it is multiple times&lt;BR /&gt;if it is just 1 then it will replace only once&lt;BR /&gt;&lt;BR /&gt;hope this helps</description>
      <pubDate>Thu, 19 Sep 2019 08:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589961#M14973</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-19T08:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to clean a character variable from some standardised character chains?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589965#M14976</link>
      <description>It helps a lot! thank you for the explanations, I really appreciate.&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 19 Sep 2019 08:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-clean-a-character-variable-from-some-standardised/m-p/589965#M14976</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2019-09-19T08:54:20Z</dc:date>
    </item>
  </channel>
</rss>

