<?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 do I preserve line breaks in string variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617840#M181122</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, agreed the line break does exist in the macro variable, but as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83374"&gt;@DWilson&lt;/a&gt;&amp;nbsp;has also experienced, depending on how / where it is displayed the line break is not always honoured.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to your question:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What is it that you need to do that you cannot do now?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be clear, I was just trying to come up with a way forward for the OP (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307179"&gt;@mmmaria&lt;/a&gt;), but as mentioned the line break ('0A'x) isn't always present when copying and pasting from the log for me. As in my last post, there are probably differences in setup at play here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Until it is made clear how the text is to be put to use by the OP, I think it won't be easy to come to a conclusive solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2020 17:46:53 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2020-01-16T17:46:53Z</dc:date>
    <item>
      <title>How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617396#M180913</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to find a way to preserve line breaks/carriage returns in a string variable. Everywhere I've looked people are getting rid of them and I'm dealing with an opposite issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of what I'm dealing with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvPatternTxt = nullTxt;&amp;nbsp;

proc sql;
select TEMPLATE_TXT
into :mvPatternTxt separated by ' '&amp;nbsp;
from &amp;lt;Oracle table containing template text with line breaks&amp;gt;
where &amp;lt;...&amp;gt;;

quit;

data mvTable;
MSG_TXT = "%nrbquote(&amp;amp;mvPatternTxt.)";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The field from my Oracle table which is recorded into mvPatternTxt in the proc sql looks something like this and this exact formatting must be preserved in the end result:&lt;/P&gt;&lt;PRE&gt;"Hello,

this is some text containing line breaks


1 2 3"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently the end result looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;"Hello, this is some text containing line breaks 1 2 3"&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to preserve line breaks inside a string variable and why are they automatically removed during data step/using nrbquote (I've tried bquote and superq getting the same result)? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2020 10:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617396#M180913</guid>
      <dc:creator>mmmaria</dc:creator>
      <dc:date>2020-01-15T10:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617398#M180914</link>
      <description>&lt;P&gt;Why the macro detour?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mvtable;
set
  &amp;lt;Oracle table containing template text with line breaks&amp;gt;
  (where=( &amp;lt;...&amp;gt;))
  end=done
;
length msg_txt $32767; /* maximum */
retain msg_txt;
msg_txt = catx(' ',msg_txt,template_txt);
if done;
keep msg_txt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jan 2020 10:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617398#M180914</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-15T10:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617401#M180915</link>
      <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer! Loading the entire table into SAS wouldn't be optimal as it is very large. My code snippets are taken from a bigger SAS program featuring various macros, and msg_txt is later used in some of them, so it needs to be a macro variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps there's a way to modify the table contents placing some sort of special symbol to signify line breaks that would be interpreted by SAS correctly? I've tried putting /n but it didn't get interpreted as a line break.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also looking for a confirmation (?) that SAS data step will remove all line breaks if that is the case, so if anyone can link me to such confirmation that would be helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2020 11:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617401#M180915</guid>
      <dc:creator>mmmaria</dc:creator>
      <dc:date>2020-01-15T11:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617743#M181076</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307179"&gt;@mmmaria&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you considered a replacing the line breaks with a character that isn't used in the same variable and then create a line break when required?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g. The following code sets up the data with line breaks and then replaces them when selected in SQL:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create data with line breaks; hex value '0A' is newline in Unix */
data have;
   length template_txt $ 200;

   template_txt = cats('"Hello,','0A'x,'0A'x,'this is some text containing line breaks','0A'x,'0A'x,'0A'x,'1 2 3"');
run;

/* select and replace line breaks with a unique character */
proc sql noprint;
   select
      tranwrd(template_txt,'0A'x,'~')
   into
      :mvPatternTxt separated by ' '
   from
      have
   where
      1 /* your criteria */
   ;
quit;

%put mvPatternTxt = &amp;amp;mvPatternTxt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above gives:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;mvPatternTxt = "Hello,~~this is some text containing line breaks~~~1 2 3"&lt;/PRE&gt;&lt;P&gt;Assuming you later need to print out the value of &lt;FONT face="courier new,courier"&gt;&amp;amp;mvPatternTxt&lt;/FONT&gt;, you can do some text processing (e.g., using the &lt;FONT face="courier new,courier"&gt;scan()&lt;/FONT&gt; function) to display the different parts on different lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 12:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617743#M181076</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-16T12:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617771#M181088</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22588"&gt;@Amir&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307179"&gt;@mmmaria&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you considered a replacing the line breaks with a character that isn't used in the same variable and then create a line break when required?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g. The following code sets up the data with line breaks and then replaces them when selected in SQL:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create data with line breaks; hex value '0A' is newline in Unix */
data have;
   length template_txt $ 200;

   template_txt = cats('"Hello,','0A'x,'0A'x,'this is some text containing line breaks','0A'x,'0A'x,'0A'x,'1 2 3"');
run;

/* select and replace line breaks with a unique character */
proc sql noprint;
   select
      tranwrd(template_txt,'0A'x,'~')
   into
      :mvPatternTxt separated by ' '
   from
      have
   where
      1 /* your criteria */
   ;
quit;

%put mvPatternTxt = &amp;amp;mvPatternTxt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above gives:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;mvPatternTxt = "Hello,~~this is some text containing line breaks~~~1 2 3"&lt;/PRE&gt;&lt;P&gt;Assuming you later need to print out the value of &lt;FONT face="courier new,courier"&gt;&amp;amp;mvPatternTxt&lt;/FONT&gt;, you can do some text processing (e.g., using the &lt;FONT face="courier new,courier"&gt;scan()&lt;/FONT&gt; function) to display the different parts on different lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;After creating a data set from proc sql, why not just apply &lt;CODE class=" language-sas"&gt;tranwrd&lt;/CODE&gt; again to replace the ~ with '0A'x ? No further text processing required?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 14:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617771#M181088</guid>
      <dc:creator>DWilson</dc:creator>
      <dc:date>2020-01-16T14:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617779#M181092</link>
      <description>&lt;P&gt;&lt;STRONG&gt;What makes you think the line breaks are gone?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Let's do a little test.&amp;nbsp; First create a macro variable with CR and LF characters in it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('mvPatternTxt'
  ,cat('AAA','0D0A'x,'BBB','0D0A'x,'CCC')
  );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now pull the value into a dataset variable.&amp;nbsp; You can use SYMGET() or just expand the macro variable inside quotes to make a string literal. Either way the "line break" characters are still there.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  length str1 str2 $200;
  str1=symget('mvPatternTxt');
  str2="%superq(mvPatternTxt)";
  put (str1 str2) (/=);
  put (str1 str2) (/= $hex26.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you can tell from the hex codes that the OD and OA characters are still there.&lt;/P&gt;
&lt;PRE&gt;str1=4141410D0A4242420D0A434343
str2=4141410D0A4242420D0A434343
&lt;/PRE&gt;
&lt;P&gt;And on the SAS log window it might look like they are not there.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 163px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35384iFBE3B584E834F50F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But if I copy and paste the text from the log they are there.&lt;/P&gt;
&lt;PRE&gt;str1=AAA
BBB
CCC
str2=AAA
BBB
CCC

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 15:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617779#M181092</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-16T15:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617791#M181101</link>
      <description>&lt;P&gt;One small note. Instead copying from log we can just print them (with \r\n) into the text file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename t temp;
data _null_;
  file t;
  length str1 str2 $200;
  str1=symget('mvPatternTxt');
  str2="%superq(mvPatternTxt)";
  put str1 / str2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 15:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617791#M181101</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-16T15:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617809#M181108</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83374"&gt;@DWilson&lt;/a&gt;, Thanks for your suggestion, that was my original thinking too, but, before I did the text substitution, I tried copying the result of &lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;amp;mvPatternTxt&lt;/SPAN&gt;&lt;/FONT&gt;, as displayed in the log and pasting it into a text editor and no line breaks appeared (I also looked at the hex characters in the text editor). This appears to be different to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has experienced. So that is why I suggested the approach I did and to manually process the text when required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subsequent to the post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;, I tried writing the value of&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;&amp;amp;mvPatternTxt&lt;/FONT&gt; directly to an external file using a data step and I then do see the line breaks required:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Hello,

this is some text containing line breaks


1 2 3
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps I have a different setup.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 16:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617809#M181108</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-16T16:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617811#M181110</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22588"&gt;@Amir&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83374"&gt;@DWilson&lt;/a&gt;, Thanks for your suggestion, that was my original thinking too, but, before I did the text substitution, I tried copying the result of &lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;amp;mvPatternTxt&lt;/SPAN&gt;&lt;/FONT&gt;, as displayed in the log and pasting it into a text editor and no line breaks appeared (I also looked at the hex characters in the text editor). This appears to be different to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has experienced. So that is why I suggested the approach I did and to manually process the text when required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subsequent to the post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;, I tried writing the value of&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;&amp;amp;mvPatternTxt&lt;/FONT&gt; directly to an external file using a data step and I then do see the line breaks required:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Hello,

this is some text containing line breaks


1 2 3
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps I have a different setup.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So it sounds like you are getting the line breaks in your macro variable.&lt;/P&gt;
&lt;P&gt;What is it that you need to do that you cannot do now?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 16:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617811#M181110</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-16T16:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617818#M181114</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22588"&gt;@Amir&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83374"&gt;@DWilson&lt;/a&gt;, Thanks for your suggestion, that was my original thinking too, but, before I did the text substitution, I tried copying the result of &lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;amp;mvPatternTxt&lt;/SPAN&gt;&lt;/FONT&gt;, as displayed in the log and pasting it into a text editor and no line breaks appeared (I also looked at the hex characters in the text editor). This appears to be different to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has experienced. So that is why I suggested the approach I did and to manually process the text when required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subsequent to the post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;, I tried writing the value of&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;&amp;amp;mvPatternTxt&lt;/FONT&gt; directly to an external file using a data step and I then do see the line breaks required:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Hello,

this is some text containing line breaks


1 2 3&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps I have a different setup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The carriage return/line feed character is non-printable. I suppose that SAS strips those out when "printing" to the log file. When you then copy the string in the log you are copying a string that has no non-printable character (by definition I guess.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hrm, Tom says he copies the string from the log and the non-printing characters are there. Maybe he's using HTML log output and not listing? I wouldn't think that non-printing characters would be preserved in a log using list output; but what do I know.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SIGH: Actually, I only use list output and I'm not sure if the different output settings actually changes how log output is stored.&amp;nbsp; I suspect I'm off-base about something.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok, I just tested this with SAS EG on windows and SAS 9.4 TS1M3 running on a remote linux SAS grid environment.&lt;/P&gt;&lt;P&gt;x="Test"||"0A"x||"This";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;printing this with list output produces:&lt;/P&gt;&lt;P&gt;TestThis&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;printing this with HTML output produces:&lt;/P&gt;&lt;P&gt;Test This&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Printing this with SAS report output produces:&lt;/P&gt;&lt;P&gt;Test&lt;/P&gt;&lt;P&gt;This&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In all three cases, putting to the log shows:&lt;/P&gt;&lt;P&gt;TestThis&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 16:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617818#M181114</guid>
      <dc:creator>DWilson</dc:creator>
      <dc:date>2020-01-16T16:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617840#M181122</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, agreed the line break does exist in the macro variable, but as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83374"&gt;@DWilson&lt;/a&gt;&amp;nbsp;has also experienced, depending on how / where it is displayed the line break is not always honoured.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to your question:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What is it that you need to do that you cannot do now?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be clear, I was just trying to come up with a way forward for the OP (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307179"&gt;@mmmaria&lt;/a&gt;), but as mentioned the line break ('0A'x) isn't always present when copying and pasting from the log for me. As in my last post, there are probably differences in setup at play here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Until it is made clear how the text is to be put to use by the OP, I think it won't be easy to come to a conclusive solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/617840#M181122</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-16T17:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618038#M181235</link>
      <description>&lt;P&gt;Hi Tom, everyone -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the end destination of this text containing line breaks is a different Oracle table, which it's written into after passing through a series of other SAS scripts and macros. The destination table field value contains no line breaks and that's how I know they get lost in the process. We need the line breaks bc the text is an instruction and is illegible without them. It's a shame if removing line breaks is a feature of SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone for your suggestions and participation, along with some colleagues we've also come up with the strategy to convert line breaks to special symbols and convert them back before writing to the destination table. Hopefully we'll manage to implement this. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 10:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618038#M181235</guid>
      <dc:creator>mmmaria</dc:creator>
      <dc:date>2020-01-17T10:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618047#M181240</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the initial data contain end of line symbols, right? They are also extracted from oracle database into some sas dataset, right?&amp;nbsp;&lt;/P&gt;&lt;P&gt;If at the entrance to the process you have data(with 0Ax and 0Dx) in a variable it must be something wrong with data processing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working on variables itself doesn't remove 0Ax and 0Dx (check out the code below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  var1 = cat('A  A  A','0D0A'x,'B  B  B','0D0A'x,'C  C  C');
run;

data want;
  set have;
  var2 = var1;
  call symputX('mvPatternTxt', var2);
run;

filename t temp;
data _null_;
  set want;
  file t;
  length str1 str2 $200;
  str1=symget('mvPatternTxt');
  str2="%superq(mvPatternTxt)";

  var3 = compbl(var1);

  put str1 / str2 / var1 / var2 / var3;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 11:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618047#M181240</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-01-17T11:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618049#M181242</link>
      <description>&lt;P&gt;I've played around with this problem. The linefeeds are removed when you call symput or call execute (e.g. a title statement).&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 11:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618049#M181242</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-17T11:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618052#M181244</link>
      <description>&lt;P&gt;So I've tried to first replace the line breaks in Oracle using&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;translate (column, chr(10), '~')&lt;/PRE&gt;&lt;P&gt;which worked. I put chr(10)||chr(13) but 10 is what got picked up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now I'm trying to convert this into the proc sql in my script and the line breaks (I've tried putting '0D'x, '0D0A'x and '0D'x||'0A'x since it won't recognize chr()?) are not getting picked up, nor does any character I've tried. Any ideas how to use the Oracle translate function inside a proc sql or what to replace it with? Sorry this is getting a little off topic.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 11:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618052#M181244</guid>
      <dc:creator>mmmaria</dc:creator>
      <dc:date>2020-01-17T11:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618058#M181247</link>
      <description>&lt;P&gt;Are you looking for the&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1jfxetjdn0nxan1w4e64c7rouz9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;byte()&lt;/A&gt;&amp;nbsp;function in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps show us the &lt;FONT face="courier new,courier"&gt;proc sql&lt;/FONT&gt; code so that we can better understand the context.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 12:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618058#M181247</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-17T12:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618062#M181250</link>
      <description>&lt;P&gt;The proc sql looks something like this at the moment:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

select 
translate (template_txt, '0D0A'x, '~') as template_txt
into :mvPatternTxt separated by ' '
from &amp;lt;Oracle table&amp;gt; dict
where dict.template_id = 123;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The final code will be more complicated (case clause on template_txt field depending on which dictionary table is being used (table name postfix determined by variable, replace line breaks if it's "...ABC", else select template_txt as is) + multiple other fields selected as is) but I'm trying to get at least this to work for now. Currently it's replacing line breaks with blanks/spaces just like at the very beginning.&lt;/P&gt;&lt;P&gt;I thought maybe the issue was with encoding or something of the sort but it won't even replace/pick up numbers like '1' or ordinary letters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 12:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618062#M181250</guid>
      <dc:creator>mmmaria</dc:creator>
      <dc:date>2020-01-17T12:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618069#M181253</link>
      <description>&lt;P&gt;If I've understood correctly, you're trying to do what I initially posted, i.e., use &lt;FONT face="courier new,courier"&gt;tranwrd()&lt;/FONT&gt; in the &lt;FONT face="courier new,courier"&gt;proc sql&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create data with line breaks; hex value '0A' is newline in Unix */
data have;
   length template_txt $ 200;

   template_txt = cats('"Hello,','0A'x,'0A'x,'this is some text containing line breaks','0A'x,'0A'x,'0A'x,'1 2 3"');
run;

/* select and replace line breaks with a unique character */
proc sql noprint;
   select
      tranwrd(template_txt,'0A'x,'~')
   into
      :mvPatternTxt separated by ' '
   from
      have
   where
      1 /* your criteria */
   ;
quit;

%put mvPatternTxt = &amp;amp;mvPatternTxt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This shows the following in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;mvPatternTxt = "Hello,~~this is some text containing line breaks~~~1 2 3"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 13:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618069#M181253</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-17T13:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618079#M181261</link>
      <description>Yes, tranwrd() worked, thank you so much! I wasn't sure it would inside proc sql.</description>
      <pubDate>Fri, 17 Jan 2020 13:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618079#M181261</guid>
      <dc:creator>mmmaria</dc:creator>
      <dc:date>2020-01-17T13:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve line breaks in string variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618083#M181263</link>
      <description>&lt;P&gt;Glad to hear you got it working. Remember to mark whichever post you feel appropriate as the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any further queries then please create a new question and you can always provide a link back to this one if necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 14:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-preserve-line-breaks-in-string-variable/m-p/618083#M181263</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-01-17T14:00:08Z</dc:date>
    </item>
  </channel>
</rss>

