<?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: XML Mapper Want filename as a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/670525#M201308</link>
    <description>&lt;P&gt;Are you asking if there is a way in your map file to specify that when you use it to convert an XML file to a SAS dataset that the name of the XML being converted? I would be very surprised if that is possible as why would the map file know anything about the source of the file that it is being used to parse?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do that in separate logic.&amp;nbsp; Let's setup an example by creating an XML file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname out xmlv2 'c:\downloads\class1.xml';
data out.class; set sashelp.class; run;
libname out clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's read that back into a SAS dataset and use the PATHNAME() function to find the path that the libref being used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in xmlv2 'c:\downloads\class1.xml';
data class;
  set in.class ;
  filename=pathname('in');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    Name            Sex         Age      Height      Weight           filename

  1    Alfred            M          14          69       112.5    c:\downloads\class1.xml
  2    Alice             F          13        56.5          84    c:\downloads\class1.xml
  3    Barbara           F          13        65.3          98    c:\downloads\class1.xml
  4    Carol             F          14        62.8       102.5    c:\downloads\class1.xml
  5    Henry             M          14        63.5       102.5    c:\downloads\class1.xml
  6    James             M          12        57.3          83    c:\downloads\class1.xml
  7    Jane              F          12        59.8        84.5    c:\downloads\class1.xml
  8    Janet             F          15        62.5       112.5    c:\downloads\class1.xml
  9    Jeffrey           M          13        62.5          84    c:\downloads\class1.xml
 10    John              M          12          59        99.5    c:\downloads\class1.xml
 11    Joyce             F          11        51.3        50.5    c:\downloads\class1.xml
 12    Judy              F          14        64.3          90    c:\downloads\class1.xml
 13    Louise            F          12        56.3          77    c:\downloads\class1.xml
 14    Mary              F          15        66.5         112    c:\downloads\class1.xml
 15    Philip            M          16          72         150    c:\downloads\class1.xml
 16    Robert            M          12        64.8         128    c:\downloads\class1.xml
 17    Ronald            M          15          67         133    c:\downloads\class1.xml
 18    Thomas            M          11        57.5          85    c:\downloads\class1.xml
 19    William           M          15        66.5         112    c:\downloads\class1.xml
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 19 Jul 2020 22:01:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-07-19T22:01:45Z</dc:date>
    <item>
      <title>XML Mapper Want filename as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/669899#M201020</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using XML Mapper engine xmlv2.&amp;nbsp; I am using a map to load 2 or more XML files.&amp;nbsp; I would like to modify the map to have the file name as one of the variables.&amp;nbsp; Any knows how can I get the filenames as part of the variables in my dataset?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/669899#M201020</guid>
      <dc:creator>ismahero1</dc:creator>
      <dc:date>2020-07-16T15:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: XML Mapper Want filename as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/670512#M201303</link>
      <description>&lt;P&gt;This is unclear. Please give an example of want you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 20:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/670512#M201303</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-19T20:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: XML Mapper Want filename as a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/670525#M201308</link>
      <description>&lt;P&gt;Are you asking if there is a way in your map file to specify that when you use it to convert an XML file to a SAS dataset that the name of the XML being converted? I would be very surprised if that is possible as why would the map file know anything about the source of the file that it is being used to parse?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do that in separate logic.&amp;nbsp; Let's setup an example by creating an XML file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname out xmlv2 'c:\downloads\class1.xml';
data out.class; set sashelp.class; run;
libname out clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's read that back into a SAS dataset and use the PATHNAME() function to find the path that the libref being used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in xmlv2 'c:\downloads\class1.xml';
data class;
  set in.class ;
  filename=pathname('in');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    Name            Sex         Age      Height      Weight           filename

  1    Alfred            M          14          69       112.5    c:\downloads\class1.xml
  2    Alice             F          13        56.5          84    c:\downloads\class1.xml
  3    Barbara           F          13        65.3          98    c:\downloads\class1.xml
  4    Carol             F          14        62.8       102.5    c:\downloads\class1.xml
  5    Henry             M          14        63.5       102.5    c:\downloads\class1.xml
  6    James             M          12        57.3          83    c:\downloads\class1.xml
  7    Jane              F          12        59.8        84.5    c:\downloads\class1.xml
  8    Janet             F          15        62.5       112.5    c:\downloads\class1.xml
  9    Jeffrey           M          13        62.5          84    c:\downloads\class1.xml
 10    John              M          12          59        99.5    c:\downloads\class1.xml
 11    Joyce             F          11        51.3        50.5    c:\downloads\class1.xml
 12    Judy              F          14        64.3          90    c:\downloads\class1.xml
 13    Louise            F          12        56.3          77    c:\downloads\class1.xml
 14    Mary              F          15        66.5         112    c:\downloads\class1.xml
 15    Philip            M          16          72         150    c:\downloads\class1.xml
 16    Robert            M          12        64.8         128    c:\downloads\class1.xml
 17    Ronald            M          15          67         133    c:\downloads\class1.xml
 18    Thomas            M          11        57.5          85    c:\downloads\class1.xml
 19    William           M          15        66.5         112    c:\downloads\class1.xml
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 22:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/XML-Mapper-Want-filename-as-a-variable/m-p/670525#M201308</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-19T22:01:45Z</dc:date>
    </item>
  </channel>
</rss>

