<?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: Issues about separation of lengthy character variable values(in multiple sentences) in sas 9.4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806141#M317575</link>
    <description>&lt;P&gt;Hex code for LF is '0A'x not 'A0'x, so that might be part of the problem. However, if '0A'x is putting a hex on your data (sorry&amp;nbsp; - couldn't resist)&amp;nbsp; maybe just replace the '0A'x values with '. '? That code would look something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Example data */
data have;
   Comment=cats("Not preferable to eat",'0A'x,"Do not buy for consumption");output;
   Comment=cats("Preferred edible",'0A'x,"Fit for human consumption");output;
run;

title "&amp;amp;syslast";
proc print; run;

/* Replace the LF character with '. ' */
data want;
   set have;
   Comment=translate(comment,'. ','0A'x);
run;

title "&amp;amp;syslast";
proc print; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 20:05:35 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2022-04-05T20:05:35Z</dc:date>
    <item>
      <title>Issues about separation of lengthy character variable values(in multiple sentences) in sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806139#M317574</link>
      <description>&lt;P&gt;Hi experts;&lt;/P&gt;
&lt;P&gt;I have imported data from an excel (xlsx) file into a SAS dataset. One of the variables has multiple values (ranging up to 400 characters) under it and the value shows up like this:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;VariableName&lt;/STRONG&gt;&lt;/U&gt;&lt;STRONG&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; &lt;U&gt;VariableValues&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Comment&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; &amp;nbsp;&lt;FONT color="#FF0000"&gt;Not preferable to &lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; eatDo not buy for &lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;consumption&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to separate and reassign the value as follows:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;data want;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;set have;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;If comment = "Not preferable to eatDo not buy for consumption" then comment= "Not preferable to eat. Do not buy for consumption." ;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;It still returned&amp;nbsp;&lt;EM&gt;"Not preferable to eatDo not buy for consumption" &lt;/EM&gt;under the &lt;STRONG&gt;comment&lt;/STRONG&gt; .&lt;/P&gt;
&lt;P&gt;When I copy the values from the SAS dataset and paste it in SAS work space, it prints the values in two lines (with a blank line in between) as follows:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;Not preferable to eat&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#00FF00"&gt;(Here is a blank line)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Do not buy for consumption&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;I even tried following data cleaning techniques in the previous step:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;comment = left(upcase(compress(comment, 'A0'x)));&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;comment = left(upcase(compbl(comment)));&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;It still didn't help. Any suggestions what I did wrong?&lt;/P&gt;
&lt;P&gt;Thanks for support.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 19:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806139#M317574</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2022-04-05T19:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Issues about separation of lengthy character variable values(in multiple sentences) in sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806141#M317575</link>
      <description>&lt;P&gt;Hex code for LF is '0A'x not 'A0'x, so that might be part of the problem. However, if '0A'x is putting a hex on your data (sorry&amp;nbsp; - couldn't resist)&amp;nbsp; maybe just replace the '0A'x values with '. '? That code would look something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Example data */
data have;
   Comment=cats("Not preferable to eat",'0A'x,"Do not buy for consumption");output;
   Comment=cats("Preferred edible",'0A'x,"Fit for human consumption");output;
run;

title "&amp;amp;syslast";
proc print; run;

/* Replace the LF character with '. ' */
data want;
   set have;
   Comment=translate(comment,'. ','0A'x);
run;

title "&amp;amp;syslast";
proc print; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 20:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806141#M317575</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-04-05T20:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Issues about separation of lengthy character variable values(in multiple sentences) in sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806142#M317576</link>
      <description>&lt;P&gt;Figure out what is actually in the variable since it is NOT the string you tried in the IF statement.&lt;/P&gt;
&lt;P&gt;Most likely there are some invisible characters in there.&amp;nbsp; Things to check for are things like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'09'x - Tab&lt;/P&gt;
&lt;P&gt;'0A'x - Line Feed&lt;/P&gt;
&lt;P&gt;'0D'x - Carrriage Return&lt;/P&gt;
&lt;P&gt;'00'x - Null&lt;/P&gt;
&lt;P&gt;'FF'x - ??&lt;/P&gt;
&lt;P&gt;'A0'x - Non breaking space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do the strings have any non standard characters, like accented characters or strange graphical symbols?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you just want to change all of the weird characters into spaces?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;comment = compbl(translate(comment,' ',compress(comment,collate(32,126))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use TRANSLATE to convert any character in the string that is not in the ASCII codes between a space and a tilde.&lt;/P&gt;
&lt;P&gt;Use COMPBL to convert multiple adjacent spaces into one space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 20:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-about-separation-of-lengthy-character-variable-values-in/m-p/806142#M317576</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-05T20:04:59Z</dc:date>
    </item>
  </channel>
</rss>

