<?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: Preserve line breaks in PROC PRINT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862750#M340786</link>
    <description>&lt;P&gt;Thanks a ton, works like a charm.. ASIS seems to be not available in PROC PRINT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc print noobs;  
var newstring;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 18:21:44 GMT</pubDate>
    <dc:creator>deepanshu88us0</dc:creator>
    <dc:date>2023-03-07T18:21:44Z</dc:date>
    <item>
      <title>Preserve line breaks from JSON data in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862710#M340769</link>
      <description>&lt;P&gt;After putting&amp;nbsp;&lt;STRONG&gt;$hex48. &lt;/STRONG&gt;in &lt;STRONG&gt;format &lt;/STRONG&gt;statement I can see the line breaks&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;0A..&lt;/SPAN&gt;&lt;/STRONG&gt; It means line breaks are in the dataset but when it prints it does not display with the line breaks..so it seems any option in proc print solve this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc print data=df noobs ;
var content / style = [fontsize=14pt];
format content $hex48.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 15:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862710#M340769</guid>
      <dc:creator>deepanshu88us0</dc:creator>
      <dc:date>2023-03-08T15:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862723#M340772</link>
      <description>&lt;P&gt;The text you shared does not appear to be a fully formed JSON file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;8427   libname json json ;
NOTE: JSON data is only read once.  To read the JSON again, reassign the JSON LIBNAME.
ERROR: Invalid JSON in input near line 1 column 4: Text must begin with an object or array open.
ERROR: Error in the LIBNAME statement.
8428
&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862723#M340772</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T17:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862730#M340773</link>
      <description>&lt;PRE&gt;JSON&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862730#M340773</guid>
      <dc:creator>deepanshu88us0</dc:creator>
      <dc:date>2023-03-07T18:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862733#M340775</link>
      <description>&lt;P&gt;It seems to complaining about the random line breaks you have inserted into the middle of that one value.&lt;/P&gt;
&lt;P&gt;So you can remove them and the file will work:&lt;/P&gt;
&lt;P&gt;Let's re-create your posted text as a file, let's use JSONRAW as the fileref&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=jsonraw;
filename jsonraw temp ;
parmcards4;
{
   "id": "c",
   "object": "ch",
   "created": 1678202926,
   "model": "g",
   "usage": {
     "prompt_tokens": 12,
     "completion_tokens": 192,
     "total_tokens": 204
   },
   "choices": [
     {
       "message": {
         "role": "assistant",
         "content": "\n\nHere's an example Python code to remove duplicates from a list:\n\n```python\nmy_list = [1, 2, 3, 1, 2, 4, 
 5, 5]\n\n# Use a set to remove duplicates\nunique_list = list(set(my_list))\n\nprint(unique_list)\n```\n\nOutput:\n\n```\n[1, 2, 3, 
 4, 5]\n```\n\nAlternatively, you can also use a for loop to iterate through the list and create a new list with only unique 
 elements:\n\n```python\nmy_list = [1, 2, 3, 1, 2, 4, 5, 5]\n\nunique_list = []\nfor element in my_list:\n    if element not in 
 unique_list:\n        unique_list.append(element)\n\nprint(unique_list)\n```\n\nOutput:\n\n```\n[1, 2, 3, 4, 5]\n```"
       },
       "finish_reason": null,
       "index": 0
     }
   ]
 }
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if you just copy it to file without the line breaks it will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename json temp;
data _null_;
  infile jsonraw;
  file json recfm=n;
  input;
  put _infile_ @;
run;
libname json json ;

proc copy inlib=json outlib=work;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the line breaks to actually be part of the value you need to insert \n , like the ones it already has.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename json temp;
data _null_;
  infile jsonraw;
  file json recfm=n;
  input;
  retain nq;
  nq=mod(sum(nq,countc(_infile_,'"')),2);
  put _infile_ @;
  if nq then put '\n' @;
run;
libname json json ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862733#M340775</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T17:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862734#M340776</link>
      <description>&lt;P&gt;What does this question have to do with PROC PRINT?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862734#M340776</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T17:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862739#M340779</link>
      <description>&lt;P&gt;I apologize I couldn't explain in clearer manner.. Let me explain what I am doing-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal : To print the output in SAS like in the image. This is what I am trying to do with PROC PRINT.&amp;nbsp; When I used hexcode in the format statement I can see line break in the dataset (see my original post - I updated the post).. Hope it makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like it's nothing to do with JSON.. It's to do with PROC PRINT if an observation has text which contains line breaks so when user prints it.. it does not show in results window...But we can see line breaks in hex code.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862739#M340779</guid>
      <dc:creator>deepanshu88us0</dc:creator>
      <dc:date>2023-03-07T18:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862744#M340784</link>
      <description>&lt;P&gt;If you want ODS to print a line break try changing the linefeeds into ODS newline commands.&amp;nbsp;&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsug/p11xia2ltavr8ln17srq8vn4rnqc.htm#p0xwm6sfkghhpsn1gi5ky18f6qkx" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsug/p11xia2ltavr8ln17srq8vn4rnqc.htm#p0xwm6sfkghhpsn1gi5ky18f6qkx&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;string=tranwrd(string,'0a'x,'^{newline}');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could split the strings into multiple observations and print those.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_print;
  set have;
  do row=1 to max(1,countw(string,'0A'x);
     newstring=scan(string,row,'0A'x);
     output;
  end;
  drop string;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to include the ASIS option to preserve the leading spaces.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862744#M340784</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T18:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Preserve line breaks in PROC PRINT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862750#M340786</link>
      <description>&lt;P&gt;Thanks a ton, works like a charm.. ASIS seems to be not available in PROC PRINT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc print noobs;  
var newstring;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Preserve-line-breaks-from-JSON-data-in-PROC-PRINT/m-p/862750#M340786</guid>
      <dc:creator>deepanshu88us0</dc:creator>
      <dc:date>2023-03-07T18:21:44Z</dc:date>
    </item>
  </channel>
</rss>

