<?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: Suppress Line Breaks in JSON Output with HTML Code in String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869397#M343397</link>
    <description>&lt;P&gt;You have a string with 1,800 thousand linefeed or carriage return characters?&lt;/P&gt;
&lt;P&gt;Something is either wrong with the source data or the program you used to to implement the COMPRESS() function call.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2023 11:54:31 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-04-12T11:54:31Z</dc:date>
    <item>
      <title>Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869147#M343328</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am using a data _null_ statement to create a JSON output file that I then reference using proc http.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have ran into an issue with the JSON output containing line breaks for one of my put statements. This is due to the fact that the variable I am referencing in the specific put statement&amp;nbsp; has HTML code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro update;
%do i = 2 %to 3;
data _null_;
file "XXXXX_&amp;amp;i..json";
  set _final_b&amp;amp;i end=eof;
  if _n_=1 then put '[' / ' {' @;
  else put ',{' @;
  put 
    '"id":' id
  /' ,"type":' type :$quote.
  /' ,"map_price":' map_price
  /' ,"fixed_cost_shipping_price":' fixed_cost_shipping_price
  /' ,"is_free_shipping":' is_free_shipping_alt
  /' ,"availability_description":' availability_description :$quote.
  /' ,"page_title":' page_title :$quote.
  /' ,"meta_description":' meta_description :$quote.
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;  /' ,"description":' description :$quote.&lt;/FONT&gt;&lt;/STRONG&gt; (this field has the HTML that is getting output with multiple line breaks)
  /' ,"name":' name :$quote.
  /' ,"price":' price
  /' ,"weight":' weight
  /' }'
  ;
  ;
  if eof then put ']';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This issue is with respect to the description variable. Here is an example of what that variable looks like:&lt;/P&gt;&lt;P&gt;&amp;lt;h3&amp;gt;Description&amp;lt;/h3&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Hello this is the product description&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Here is some further information&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can suppress the line breaks when outputting a JSON file? Many of my descriptions have lengths&amp;gt;1000 and numerous HTML code creating the line breaks.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 16:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869147#M343328</guid>
      <dc:creator>CR-Horton</dc:creator>
      <dc:date>2023-04-11T16:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869162#M343335</link>
      <description>&lt;P&gt;I'm confused, if the value of description is&amp;nbsp;"&amp;lt;h3&amp;gt;Description&amp;lt;/h3&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Hello this is the product description&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Here is some further information&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;" then that value doesn't have any line breaks in it.&amp;nbsp; Some of the values are HTML tags that will create an unordered list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What value would you want to write to the JSON file?&amp;nbsp; Would you want to remove the tags &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt; so you would have description="&amp;lt;h3&amp;gt;Description&amp;lt;/h3&amp;gt;Hello this is the product descriptionHere is some further information" ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to look into PROC JSON for generating JSON files, rather than writing the file with PUT statements.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 17:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869162#M343335</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-11T17:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869163#M343336</link>
      <description>&lt;P&gt;No I do not want to remove the tags I am wanting everything printed in one single like. This is what the output looks like currently:&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{"id":31790&lt;BR /&gt;,"type":"physical"&lt;BR /&gt;,"map_price":0&lt;BR /&gt;,"fixed_cost_shipping_price":10&lt;BR /&gt;,"is_free_shipping":true&lt;BR /&gt;,"availability_description":""&lt;BR /&gt;,"page_title":"XXXX"&lt;BR /&gt;&lt;FONT color="#000000"&gt;,"meta_description":"XXXX"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;,"description":"&amp;lt;h3&amp;gt;Description&amp;lt;/h3&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Hello this is the product description&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Here is some further information&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;"&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;BR /&gt;,"name":"XXX"&lt;BR /&gt;,"price":18.18&lt;BR /&gt;,"weight":0.18&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;"description":"&amp;lt;h3&amp;gt;Description&amp;lt;/h3&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Hello this is the product description&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Here is some further information&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;"&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 17:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869163#M343336</guid>
      <dc:creator>CR-Horton</dc:creator>
      <dc:date>2023-04-11T17:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869168#M343341</link>
      <description>&lt;P&gt;If you have CR LF control characters in the data, you should be able to remove them with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;description= compress(description,'0D0A'x) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are other options for the optional third argument to compress that will allow you to remove all control characters.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 18:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869168#M343341</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-11T18:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869211#M343357</link>
      <description>&lt;P&gt;Your data step is NOT going to add any end of line characters to the output file UNLESS the logical recode length for the output file is shorter than the length of the string you are trying to write.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure that the data in the variable DESCRIPTION does not contain LF (or perhaps CR LF pairs)?&lt;/P&gt;
&lt;P&gt;If so you should remove those first.&lt;/P&gt;
&lt;P&gt;Perhaps with TRANSLATE() or TRANWRD() function calls.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;description=translate(description,' ','0a'x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or TRANWRD() function calls.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;description=tranwrd(description,'0d0a'x,' ');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2023 20:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869211#M343357</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-11T20:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869394#M343394</link>
      <description>/*Try recfm= option.*/&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;file "XXXXX_&amp;amp;i..json" recfm=n ;</description>
      <pubDate>Wed, 12 Apr 2023 11:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869394#M343394</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-12T11:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869396#M343396</link>
      <description>&lt;P&gt;Thanks, but I am actually not wanting to remove those characters. Those are HTML characters that I need to remain in the string.&lt;BR /&gt;&lt;BR /&gt;Using that compress function strips out all the content post the control characters and in my instance since I have strings that are 2k characters and it ends up removing 90% of the string.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 11:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869396#M343396</guid>
      <dc:creator>CR-Horton</dc:creator>
      <dc:date>2023-04-12T11:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869397#M343397</link>
      <description>&lt;P&gt;You have a string with 1,800 thousand linefeed or carriage return characters?&lt;/P&gt;
&lt;P&gt;Something is either wrong with the source data or the program you used to to implement the COMPRESS() function call.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 11:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869397#M343397</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-12T11:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress Line Breaks in JSON Output with HTML Code in String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869402#M343400</link>
      <description>&lt;P&gt;Yes, my mistake - sorry for the confusion. That compress statement worked for me.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 12:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Suppress-Line-Breaks-in-JSON-Output-with-HTML-Code-in-String/m-p/869402#M343400</guid>
      <dc:creator>CR-Horton</dc:creator>
      <dc:date>2023-04-12T12:12:24Z</dc:date>
    </item>
  </channel>
</rss>

