<?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 separate conjoined strings in long character variables in SAS 9.4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806802#M317951</link>
    <description>&lt;P&gt;Since you have a single quote in the text, you must use double quotes around the text:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length description $100;
description = "Fair weather expected todaybut tomorrow's  will be inclement";
if description = "Fair weather expected todaybut tomorrow's  will be inclement"  
then description = "Fair weather expected today. But tomorrow's will be inclement."; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Apr 2022 16:05:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-04-08T16:05:50Z</dc:date>
    <item>
      <title>How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806786#M317938</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I have a character variable with long values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;VarName&lt;/STRONG&gt;&lt;/U&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;&lt;STRONG&gt;&amp;nbsp;Value&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;description&amp;nbsp;&lt;/EM&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; &amp;nbsp; &amp;nbsp; 'Fair weather expected &lt;EM&gt;todaybut&lt;/EM&gt; tomorrow's&amp;nbsp; will be inclement' (please notice &lt;EM&gt;&lt;STRONG&gt;todaybut&lt;/STRONG&gt;&lt;/EM&gt; and absence of full stops/periods)&lt;/P&gt;
&lt;P&gt;I have imported the data from an excel (97-2003) worksheet and applied LEFT, UPCASE AND COMPRESS functions to clean and left align it in SAS table.&lt;/P&gt;
&lt;P&gt;When I tried separating the conjoined&amp;nbsp; &lt;STRIKE&gt;&lt;EM&gt;todaybut&lt;/EM&gt;&lt;/STRIKE&gt; and add periods to modify it ('Fair weather expected &lt;EM&gt;today&lt;FONT size="4"&gt;.&lt;/FONT&gt; But&lt;/EM&gt; tomorrow's will be inclement&lt;FONT size="4"&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;if description=&amp;nbsp; 'Fair weather expected todaybut tomorrow's&amp;nbsp; will be inclement'&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;then description=&amp;nbsp;'Fair weather expected today&lt;FONT size="4"&gt;.&lt;/FONT&gt; But tomorrow's will be inclement&lt;FONT size="4"&gt;.' ; &lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;run;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;It did not work and gave me the original value(s).&lt;/P&gt;
&lt;P&gt;Is there&amp;nbsp; another better way of handling this issue? Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 14:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806786#M317938</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-04-08T14:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806790#M317941</link>
      <description>&lt;P&gt;how about these code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length description $200;
  description='Fair weather expected todaybut tomorrow''s  will be inclement';
run;

data want1;
  set have;
  if description='Fair weather expected todaybut tomorrow''s  will be inclement'  then
    description='Fair weather expected today. But tomorrow''s will be inclement.';
run;

data want2;
  set have;
  description=strip(tranwrd(description,'todaybut','today. But'))||'.';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They both work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 14:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806790#M317941</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-04-08T14:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806793#M317945</link>
      <description>&lt;P&gt;Thanks for suggestion. That value is one of several values. However, does not solve the problem.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 15:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806793#M317945</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-04-08T15:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806802#M317951</link>
      <description>&lt;P&gt;Since you have a single quote in the text, you must use double quotes around the text:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length description $100;
description = "Fair weather expected todaybut tomorrow's  will be inclement";
if description = "Fair weather expected todaybut tomorrow's  will be inclement"  
then description = "Fair weather expected today. But tomorrow's will be inclement."; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Apr 2022 16:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806802#M317951</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-08T16:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806803#M317952</link>
      <description>&lt;P&gt;For a generalized solution, consider using an external spellchecker. Writing SAS code to detect syntactical errors in free text is not a promising task, to say the least.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 16:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806803#M317952</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-08T16:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806824#M317960</link>
      <description>&lt;P&gt;One issue with attempting to insert characters into an existing variable is that depending on the actual length of a specific value and the length of the value after "inserting" you can exceed the defined length and end up with truncated data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way instead of testing for along string is to use Tranwrd.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   length x $ 100; /* make sure the example has long enough value to insert*/
                   /* if you skip this then X length is defined using the value shown*/
   x = "Fair weather expected todaybut tomorrow's  will be inclement";
   x = tranwrd(x,'todaybut','today. But');
run;&lt;/PRE&gt;
&lt;P&gt;If you have very many records and/or variables this becomes extremely tedious and you would want to use a tool intended to fix such stuff.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 17:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806824#M317960</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-08T17:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate conjoined strings in long character variables in SAS 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806832#M317961</link>
      <description>Thanks, &lt;BR /&gt;I have description length set as $ 100.Your code and shared by others above are okay  and run fine on standalone basis. But the variable is part of a larger program that has to handle with various dirty data issues and is not helping in totality although everything else is cleaned up but this monster string is not cooperating at all.&lt;BR /&gt;Thank you all though.</description>
      <pubDate>Fri, 08 Apr 2022 18:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-conjoined-strings-in-long-character-variables-in/m-p/806832#M317961</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-04-08T18:54:51Z</dc:date>
    </item>
  </channel>
</rss>

