<?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 output data in same line PUT statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740836#M231491</link>
    <description>Thank you, Tom. This did exactly what I wanted it to do.</description>
    <pubDate>Wed, 12 May 2021 15:44:12 GMT</pubDate>
    <dc:creator>ea33</dc:creator>
    <dc:date>2021-05-12T15:44:12Z</dc:date>
    <item>
      <title>How to output data in same line PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740820#M231484</link>
      <description>&lt;P&gt;I need to parse an XML that is stored in a database column (the whole XML in 1 column). To get around the 32K string limit, I've split up the xml to multiple parts in a query and then tried to place them in one file for processing. Code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE work.table AS
SELECT * FROM connection to src(
SELECT date, market, 
	substring(content, 1, 30000) as xml_1,
	substring(content, 30001, 30000) as xml_2,
	substring(content, 60001, 30000) as xml_3,
	substring(content, 90001, 30000) as xml_4,
	substring(content, 120001, 30000) as xml_5,
	substring(content, 150001, 30000) as xml_6,
	substring(content, 180001, 30000) as xml_7,
	substring(content, 210001, 30000) as xml_8,
	substring(content, 240001, 30000) as xml_9
FROM table); disconnect from src; Quit;

filename xml_file 'path/xml.xml';

data _null_;
set table_from_query;
output;
file xml_file;
put xml_1 xml_2 xml_3 xml_4 ... xml_9;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It all works as I expect it, but when I look at the xml created "xml_file" In the places that they were joined (xml_i ends and xml_i+1 starts) they are not placed on the same line. Some breaks do not cause errors, but some do as they split the actual tag. Example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Interval NUM=""33""&amp;gt;
&amp;lt;IntervalEnding&amp;gt;08:15&amp;lt;/IntervalEndin          &amp;lt;----- Split causing error &amp;gt;
g&amp;gt;
&amp;lt;IntervalValue&amp;gt;63.25&amp;lt;/IntervalValue&amp;gt;
&amp;lt;/Interval&amp;gt;
&amp;lt;Interval NUM=""34""&amp;gt;
&amp;lt;IntervalEnding&amp;gt;08:30&amp;lt;/IntervalEnding&amp;gt;
&amp;lt;IntervalValue&amp;gt;50.84&amp;lt;/IntervalValue&amp;gt;
&amp;lt;/Interval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I start the new input on the same line as before? I've tried&amp;nbsp;@ after put, but it is the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated. Side note: put xml_: doesn't work instead of naming all xml_1 through xml_9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 15:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740820#M231484</guid>
      <dc:creator>ea33</dc:creator>
      <dc:date>2021-05-12T15:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to output data in same line PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740827#M231487</link>
      <description>&lt;P&gt;Two issues.&lt;/P&gt;
&lt;P&gt;First the default logical record length (LRECL) is 32,767 bytes.&amp;nbsp; You are trying to write 9*30,000 bytes.&lt;/P&gt;
&lt;P&gt;Second if you use list mode output then the PUT statement will insert a space between the values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So set a longer record length and use formatted output.&lt;/P&gt;
&lt;P&gt;Simple version. Not sure why you had the FILENAME statement but I removed it make example shorter.&amp;nbsp; Use the $CHAR format to preserve any leading spaces on any of the sub strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set table_from_query;
  file 'path/xml.xml' lrecl=1000000;
  put (xml_1-xml_9) ($char30000.) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS can normally write lines at least as long a 1,000,000 bytes.&amp;nbsp; The actual limit probably varies by version and operating system and possibly even computer memory available.&amp;nbsp; If you need longer use RECFM=N instead.&amp;nbsp; That should also remove the line breaks between observations.&amp;nbsp; Which you might or might not want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are actually including the line breaks between observations then you can probably remove the trailing spaces using $VARYING format, but you would need to figure out where the string actually ends.&amp;nbsp; For example by find the last non-empty string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set table_from_query;
  file 'path/xml.xml' lrecl=1000000;
  array xml_ [9] ;
  do last=dim(xml_) to 1 by -1 while(missing(xml_[last])); end;
  if last then do;
    do index=1 to last-1 ;
      put xml_[index] $char30000. @;
    end;
    length=lengthn(xml_[last]);
    put xml_[last] $varying30000. length @;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&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, 12 May 2021 15:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740827#M231487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-12T15:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to output data in same line PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740836#M231491</link>
      <description>Thank you, Tom. This did exactly what I wanted it to do.</description>
      <pubDate>Wed, 12 May 2021 15:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-data-in-same-line-PUT-statement/m-p/740836#M231491</guid>
      <dc:creator>ea33</dc:creator>
      <dc:date>2021-05-12T15:44:12Z</dc:date>
    </item>
  </channel>
</rss>

