<?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 How to Import an XML file via URI in SAS Viya 3.5 using the Job Execution web application? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944754#M370157</link>
    <description>&lt;P&gt;SAS can directly access XML files hosted at a remote URL when using the LIBNAME statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let url = 'https://example.com/files/myfile.xml';
libname libxml xmlv2 &amp;amp;url xmlmap='https://example.com/files/myfile.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The problem arises when we try to use the URI because I will later need to upload this file in a JobExecution form, where it generates the file's URI.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let uri = 'https://sas.example.com/files/files/cdb78937-1273-4d35-af89-5e5f00aac774/content'; /* File uploaded to SASDrive and URI copied */
libname libxml xmlv2 &amp;amp;uri xmlmap='https://example.com/files/myfile.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the case above, an error occurs. I tried to debug it in my way, and it returned the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let uri = 'https://sas.example.com/files/files/cdb78937-1273-4d35-af89-5e5f00aac774/content';

data _null_;
if fileexist("&amp;amp;uri") then
put "The file exists.";
else
put "The file was not found.";
run;

libname libxml xmlv2 &amp;amp;uri. xmlmap='https://example.com/files/myfile.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt; The file was not found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could someone help me with this?&lt;/P&gt;</description>
    <pubDate>Wed, 02 Oct 2024 16:23:21 GMT</pubDate>
    <dc:creator>arthurdpereira</dc:creator>
    <dc:date>2024-10-02T16:23:21Z</dc:date>
    <item>
      <title>How to Import an XML file via URI in SAS Viya 3.5 using the Job Execution web application?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944754#M370157</link>
      <description>&lt;P&gt;SAS can directly access XML files hosted at a remote URL when using the LIBNAME statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let url = 'https://example.com/files/myfile.xml';
libname libxml xmlv2 &amp;amp;url xmlmap='https://example.com/files/myfile.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The problem arises when we try to use the URI because I will later need to upload this file in a JobExecution form, where it generates the file's URI.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let uri = 'https://sas.example.com/files/files/cdb78937-1273-4d35-af89-5e5f00aac774/content'; /* File uploaded to SASDrive and URI copied */
libname libxml xmlv2 &amp;amp;uri xmlmap='https://example.com/files/myfile.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the case above, an error occurs. I tried to debug it in my way, and it returned the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let uri = 'https://sas.example.com/files/files/cdb78937-1273-4d35-af89-5e5f00aac774/content';

data _null_;
if fileexist("&amp;amp;uri") then
put "The file exists.";
else
put "The file was not found.";
run;

libname libxml xmlv2 &amp;amp;uri. xmlmap='https://example.com/files/myfile.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt; The file was not found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could someone help me with this?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 16:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944754#M370157</guid>
      <dc:creator>arthurdpereira</dc:creator>
      <dc:date>2024-10-02T16:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944772#M370163</link>
      <description>&lt;P&gt;I'd use PROC HTTP to download a (temporary) copy of the files. Something like this should work:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let url = https://example.com/files/myfile.xml;
filename libxml temp;
proc http url="&amp;amp;url" out=libxml;
run;

%let url = https://example.com/files/myfile.xml;
filename xmlmp temp;
proc http url="&amp;amp;url" out=xmlmp;
run;

libname libxml xmlv2 xmlmap=xmlmp;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Sep 2024 15:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944772#M370163</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-09-20T15:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944783#M370169</link>
      <description>&lt;P&gt;Yes, it can be done through PROC HTTP, but the problem is downloading via the URI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case of PROC HTTP, I would have to include other SAS parameters like &lt;STRONG&gt;&lt;EM&gt;token&lt;/EM&gt;&lt;/STRONG&gt; or &lt;STRONG&gt;&lt;EM&gt;webusername&lt;/EM&gt;&lt;/STRONG&gt;, but that’s not the case here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to access the XML file through LIBNAME XMLV2 via the URI.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 16:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/944783#M370169</guid>
      <dc:creator>arthurdpereira</dc:creator>
      <dc:date>2024-09-20T16:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945016#M370259</link>
      <description>Anyone?</description>
      <pubDate>Tue, 24 Sep 2024 10:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945016#M370259</guid>
      <dc:creator>arthurdpereira</dc:creator>
      <dc:date>2024-09-24T10:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945688#M370467</link>
      <description>&lt;P&gt;As stated before, in order to use the XMLV2 LIBNAME engine, you will need a &lt;EM&gt;local&lt;/EM&gt; copy of the file to work with. If you can't use PROC HTTP to download the copy, you can use FILENAME URL and a DATA _NULL_ step to make it.&amp;nbsp; For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Set up FILENAME URL for remote file */
filename getme url "http://mydomain.net/my_xml_data.xml";
/* Set up FILENAME TEMP for local copy */
filename local temp;

/* Read remote file and write the result to the local copy */
data _null_;
	infile getme;
	file local;
	input;
	put _infile_;
run;

/* Release connection to remote file */
filename getme clear;

/* Use XMLV2 LIBNAME engine to read the local copy */
libname local xmlv2;

/* Extract the data from the XML file however you wish */
proc copy in=local out=work;
run;

/* Clear the XMLV2 libref */
libname local clear;
/* Clear the local XML fileref. This also deletes the local copy of the XML file.*/
filename local clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 13:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945688#M370467</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-09-30T13:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945843#M370498</link>
      <description>&lt;P&gt;Thanks for your answer! The problem is that I am using Job Execution in SAS Viya to send the XML file and in this context I cannot use the HTTP PROC directly or the suggestion you made since the system creates a URI. So since the process is executed inside the Job Execution I need to work with the URI of the XML file and that is where my difficulty lies.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 20:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945843#M370498</guid>
      <dc:creator>arthurdpereira</dc:creator>
      <dc:date>2024-10-01T20:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945976#M370518</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/443120"&gt;@arthurdpereira&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your answer! The problem is that I am using Job Execution in SAS Viya to send the XML file and in this context I cannot use the HTTP PROC directly or the suggestion you made since the system creates a URI. So since the process is executed inside the Job Execution I need to work with the URI of the XML file and that is where my difficulty lies.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This bit may mean that it is time to examine the bigger picture.&lt;/P&gt;
&lt;P&gt;On the surface this sounds like: I have data in SAS. I am tranforming to XML file. So SAS can use it. But SAS isn't reading it the way I want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which looks kind of odd to me. Maybe I am missing something about the reason&amp;nbsp; XML is involved at all.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 15:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945976#M370518</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-02T15:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Import an XML file via URI in SAS Viya 3.5 using the Job Execution web application?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945981#M370521</link>
      <description>&lt;P&gt;The flow is as follows. I have a client that receives several XML files with data. He wants to see this in a macro way, I have a panel at the VA. So I proposed that he send the XML through Job Execution, and the program inserts the data into a table in SAS. The problem is that I only know the way to get the file via JE with URI and, that way, it doesn't work. That's the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I found a solution: &lt;STRONG&gt;parenturi&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename upload filesrvc parenturi="&amp;amp;SYS_JES_JOB_URI" 
  name="&amp;amp;_WEBIN_FILENAME" 
  contenttype="&amp;amp;_WEBIN_CONTENT_TYPE";

libname xml xmlv2 xmlfileref=upload xmlmap='file.map';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With this code I managed to make it recognize it as an XML file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 16:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Import-an-XML-file-via-URI-in-SAS-Viya-3-5-using-the-Job/m-p/945981#M370521</guid>
      <dc:creator>arthurdpereira</dc:creator>
      <dc:date>2024-10-02T16:26:19Z</dc:date>
    </item>
  </channel>
</rss>

