<?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: Reading xml into single cell in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945275#M370366</link>
    <description>&lt;P&gt;Read the file as BINARY instead of LINES of TEXT.&lt;/P&gt;
&lt;P&gt;So use RECFM=F or RECFM=N.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2024 20:31:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-09-25T20:31:03Z</dc:date>
    <item>
      <title>Reading xml into single cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945257#M370350</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read an xml file into a SAS dataset but I am struggeling to get all the xml code to fit into one single cell. Instead I am getting one row for every "line" in the xml document.&lt;/P&gt;&lt;P&gt;I've been using the infile statement. Perhaps there is an option I am missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;infile "\\myfile.xml";&lt;BR /&gt;format line $2000.;&lt;BR /&gt;input;&lt;BR /&gt;line = _infile_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 18:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945257#M370350</guid>
      <dc:creator>Lars_Beck</dc:creator>
      <dc:date>2024-09-25T18:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reading xml into single cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945263#M370356</link>
      <description>&lt;P&gt;Doesn't make sense to me why you want the entire contents of a file is one observation and a single variable (SAS data sets do not have "cells").&lt;/P&gt;
&lt;P&gt;You can try using a different TERMSTR setting on the Infile statement than is valid for your operating system. That option is what tells SAS you have reached the "end of a line" in a text file.&lt;/P&gt;
&lt;P&gt;If your operating system is Windows then the default characters for end of line are carriage-return and line-feed, if a Unix derivative the end of line is a line-feed.&lt;/P&gt;
&lt;P&gt;So you might try Termstr=CR which is unlikely to be the actual end of line character unless this started on an Apple computer.&lt;/P&gt;
&lt;PRE&gt;data test;
infile "\\myfile.xml"  Termstr=CR ;
format line $2000.;
input;
line = _infile_;
run;&lt;/PRE&gt;
&lt;P&gt;How sure are you that "all of the file" will fit in 2000 characters?&lt;/P&gt;
&lt;P&gt;You may have increase the LRECL on the infile&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What will you do with that resulting, pretty sure to be moderately ugly, variable?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 19:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945263#M370356</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-25T19:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reading xml into single cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945265#M370358</link>
      <description>&lt;P&gt;Thank you. It seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I might extend the length of the variable if I need to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The purpose is to read several files in this way and use regex to find the relevant information. That way I will get one row for each xml.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 19:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945265#M370358</guid>
      <dc:creator>Lars_Beck</dc:creator>
      <dc:date>2024-09-25T19:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading xml into single cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945272#M370363</link>
      <description>&lt;P&gt;I might be tempted to start with the XML library&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Libname xmlin xml '\\myfile.xml';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then take a look at that library. If the file is clean enough you should find a data set of some sort.&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;data work.somedata;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set xmlin.somedata;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;would copy that data set from the XML to the work library (or easily extend to a different library).&lt;/P&gt;
&lt;P&gt;Might be a lot easier than dealing with lots of REGEX code to parse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 20:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945272#M370363</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-25T20:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading xml into single cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945275#M370366</link>
      <description>&lt;P&gt;Read the file as BINARY instead of LINES of TEXT.&lt;/P&gt;
&lt;P&gt;So use RECFM=F or RECFM=N.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 20:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-xml-into-single-cell/m-p/945275#M370366</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-25T20:31:03Z</dc:date>
    </item>
  </channel>
</rss>

