<?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: substract text from another text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239546#M44083</link>
    <description>&lt;P&gt;Are you working with this within SAS or are you passing through to somewhere else, Oracle, Teradata etc?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Dec 2015 15:40:03 GMT</pubDate>
    <dc:creator>Steelers_In_DC</dc:creator>
    <dc:date>2015-12-16T15:40:03Z</dc:date>
    <item>
      <title>substract text from another text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239527#M44077</link>
      <description>&lt;P&gt;Hi SAS support community,&lt;/P&gt;&lt;P&gt;I am rather new to sas and would need your help on subtracting text from another text. Below is a similar example of the database I have. Basically, I would like to create a new variable which equals&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;newvar = Text_A - Text_B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Text_ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Text_A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Text_B&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A philosopher, in a wide sense, is someone who studies philosophy. The term "philosopher" comes from the Ancient Greek φιλόσοφος (philosophos), which means "lover of wisdom". The introduction of the terms "philosopher" and "philosophy" has been ascribed to the Greek thinker Pythagoras&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A philosopher, in a wide sense, is someone who studies philosophy.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A philosopher, in the more narrow and common usage, is any intellectual who has made contributions in one or more current fields of philosophy, such as aesthetics, ethics, epistemology, logic, metaphysics, social theory, and political philosophy.&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;is any intellectual who has made contributions in one or more current fields of philosophy, such as&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A philosopher may also be one who worked in the humanities or other sciences which have since split from philosophy proper over the centuries, such as the arts, history, economics, sociology, psychology, linguistics, anthropology, theology, and politics&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;centuries, such as the arts, history, economics, sociology, psychology, linguistics, anthropology, theology, and politics&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any simple way to do it? Tranwrd seems not to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jo&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 15:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239527#M44077</guid>
      <dc:creator>JoYZ</dc:creator>
      <dc:date>2015-12-16T15:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: substract text from another text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239536#M44081</link>
      <description>&lt;P&gt;Please provide an example dataset in the form of a datastep so we have something to work with. Also show code and&amp;nbsp;describe how TRANWRD "seems not work". Did you get no results? unexpected results? Too short of a result?&lt;/P&gt;
&lt;P&gt;Note: the greek letters aren't likely going to be handled nicely due to encoding and fonts.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 15:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239536#M44081</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-16T15:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: substract text from another text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239546#M44083</link>
      <description>&lt;P&gt;Are you working with this within SAS or are you passing through to somewhere else, Oracle, Teradata etc?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 15:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239546#M44083</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-12-16T15:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: substract text from another text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239575#M44092</link>
      <description>&lt;P&gt;Hi, I am working with SAS...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;I provided a xls&amp;nbsp;based (small) datafile as example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is what I got&amp;nbsp;so far:&lt;/P&gt;&lt;P&gt;proc import datafile='/folders/myfolders/Philosophers.xls' out=philosophers dbms=xls replace;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; getnames=yes;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;*first attempt to do text_a - text_b via tranwrd;&lt;/EM&gt;&lt;BR /&gt;data philosophers_newvar;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set philosophers;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;newvar = tranwrd(Text_A,Text_B,' ');&lt;BR /&gt;Run;&lt;BR /&gt;&lt;EM&gt;*Problems with tranwrd:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Problem Nr1: newvar gets cut off after 200 characters&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Problem Nr2: it only works if text_b is positioned at the end of the text;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;*Then I tried substr but I fail to determine the exact position of Text_B within Text_A;&lt;/EM&gt;&lt;BR /&gt;data philosophers_newvar;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set philopshers;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;c=length(Text_A);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;d=length(Text_B);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;e=d+1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if d&amp;gt;1 then i=substr(Text_A,e,c); *&lt;EM&gt;in case there is a text in Text_B&lt;/EM&gt;;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if d=&amp;lt;1 then i=Text_A; *&lt;EM&gt;in case there is no text in Text_B&lt;/EM&gt;;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put i;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;*for now substr only works if Text_B is positioned in the beginning of Text_A...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would need to find a reliable way to detect the exact position (start and end) of Text_B within Text_A...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks for your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239575#M44092</guid>
      <dc:creator>JoYZ</dc:creator>
      <dc:date>2015-12-16T17:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: substract text from another text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239586#M44102</link>
      <description>&lt;P&gt;JoYZ wrote:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;*Problems with tranwrd:&lt;BR /&gt;&lt;/EM&gt;&lt;EM&gt;Problem Nr1: newvar gets cut off after 200 characters&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Problem Nr2: it only works if text_b is positioned at the end of the text;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Problem 1 is in documentation for tranwrd, if the length of the new variable is not declared prior to use the length with be 200.&lt;/P&gt;
&lt;P&gt;Solution: Before using NewVAR have a line like Lenght Newvar $ 1500 ; The number has to be basically the length of the longest line you may encounter. Note there is a limit of 32767 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Prolem Nr2: not in my experience though the single space replacement&amp;nbsp;may not be quite what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use INDEX to find the position in the search string to find the postion of the target string. Then using the length of the target you use substr. But there are 3 cases to address, target at front of string, in middle and at the end. So you need to use&amp;nbsp;different lines of code to get possibly what you want.&lt;/P&gt;
&lt;P&gt;Pos = index (Text_a,Text_b);&lt;/P&gt;
&lt;P&gt;(If POS = 1 then your current substr works.)&lt;/P&gt;
&lt;P&gt;if pos &amp;gt; 1 then Newvar = cat(substr(text_a,1, Pos-1),substr(text_a, Pos + d+1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239586#M44102</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-16T17:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: substract text from another text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239700#M44141</link>
      <description>&lt;P&gt;You didn't post the result you want yet ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length Text_A Text_B $ 2000;
Text_ID=1;
Text_A='A philosopher, in a wide sense, is someone who studies philosophy. The term "philosopher" comes from the Ancient Greek φιλόσοφος (philosophos), which means "lover of wisdom". The introduction of the terms "philosopher" and "philosophy" has been ascribed to the Greek thinker Pythagoras';
Text_B="A philosopher, in a wide sense, is someone who studies philosophy.";
output;
Text_ID=2;
Text_A="A philosopher, in the more narrow and common usage, is any intellectual who has made contributions in one or more current fields of philosophy, such as aesthetics, ethics, epistemology, logic, metaphysics, social theory, and political philosophy.";
Text_B="is any intellectual who has made contributions in one or more current fields of philosophy, such as";
output;
run;
data want;
 set have;
 length pid new $ 32767;
 pid=cats('s/',Text_B,'//');;
 new=prxchange(pid,1,Text_A);
 drop pid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2015 03:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substract-text-from-another-text/m-p/239700#M44141</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-12-17T03:22:33Z</dc:date>
    </item>
  </channel>
</rss>

