<?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 file - How to rename some variable based on the information found into the map file in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/913907#M44239</link>
    <description>&lt;P&gt;To answer your last question first.&lt;/P&gt;
&lt;P&gt;NO.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do NOT change the PATH setting that is what tells it where to LOOK in the XML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just change the NAME= attribute to whatever name you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TopicHierarchy looks like a better name to me.&lt;/P&gt;
&lt;P&gt;Or perhaps just TOPIC.&lt;/P&gt;
&lt;P&gt;The shorter the better, otherwise it is extremely painful to type programs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can always put the longer text into the LABEL of the variable.&amp;nbsp; For some strange reason they call the label DESCRIPTION in the XMLMAP file.&lt;/P&gt;
&lt;PRE&gt;&amp;lt;COLUMN name="Topic"&amp;gt;
  &amp;lt;PATH syntax="XPath"&amp;gt;/Responses/Response/QID2_TEXT_8cb70e63_1kek94049fwnTopicHierarchy1&amp;lt;/PATH&amp;gt;
  &amp;lt;TYPE&amp;gt;character&amp;lt;/TYPE&amp;gt;
  &amp;lt;DATATYPE&amp;gt;string&amp;lt;/DATATYPE&amp;gt;
  &amp;lt;LENGTH&amp;gt;32&amp;lt;/LENGTH&amp;gt;
  &amp;lt;DESCRIPTION&amp;gt;QID2_TEXT_8cb70e63_1kek94049fwnTopicHierarchy1&amp;lt;/DESCRIPTION&amp;gt;
&amp;lt;/COLUMN&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 01:17:15 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-02-01T01:17:15Z</dc:date>
    <item>
      <title>XML file - How to rename some variable based on the information found into the map file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/913888#M44238</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using a proc http procedure to download an xml file from a specific web site.&lt;/P&gt;
&lt;P&gt;I am able to import this xml file into a SAS dataset.&amp;nbsp; However, the issue I am facing is that some variable name are longer than 32 characters so I am loosing precious information.&amp;nbsp; The complete name can be found in the map file more precisely in the path .&amp;nbsp; Is there a way to put map information into a SAS dataset , work on it the redo the map file for future use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example&lt;/P&gt;
&lt;PRE&gt;        &amp;lt;/COLUMN&amp;gt;
                
        &amp;lt;COLUMN name="QID2_TEXT_8cb70e63_1kek94049fwn8"&amp;gt;
                        
            &amp;lt;PATH syntax="XPath"&amp;gt;/Responses/Response/QID2_TEXT_8cb70e63_1kek94049fwnTopicHierarchy1&amp;lt;/PATH&amp;gt;
                        
            &amp;lt;TYPE&amp;gt;character&amp;lt;/TYPE&amp;gt;
                        
            &amp;lt;DATATYPE&amp;gt;string&amp;lt;/DATATYPE&amp;gt;
                        
            &amp;lt;LENGTH&amp;gt;32&amp;lt;/LENGTH&amp;gt;
                    
        &amp;lt;/COLUMN&amp;gt;
            
    &amp;lt;/TABLE&amp;gt;
    
&amp;lt;/SXLEMAP&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;So, if you look at COLUMN name=QID2_TEXT_8cb70e63_1kek94049fwn8 but the real value of that column is found in&lt;/P&gt;
&lt;P&gt;PATH syntax=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PATH syntax="XPath"&amp;gt;/Responses/Response/QID2_TEXT_8cb70e63_1kek94049fwnTopicHierarchy1&amp;lt;/PATH&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so if you eliminate the&amp;nbsp;8cb70e63_1kek94049fwn string it should gives&amp;nbsp;&lt;/P&gt;
&lt;P&gt;QID2_TEXT_TopicHierarchy1 which is the good column name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to do that in SAS&lt;/P&gt;
&lt;P&gt;If I rename the column name do I need to eliminate the&amp;nbsp;8cb70e63_1kek94049fwn string from the Path syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 21:46:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/913888#M44238</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-01-31T21:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: XML file - How to rename some variable based on the information found into the map file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/913907#M44239</link>
      <description>&lt;P&gt;To answer your last question first.&lt;/P&gt;
&lt;P&gt;NO.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do NOT change the PATH setting that is what tells it where to LOOK in the XML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just change the NAME= attribute to whatever name you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TopicHierarchy looks like a better name to me.&lt;/P&gt;
&lt;P&gt;Or perhaps just TOPIC.&lt;/P&gt;
&lt;P&gt;The shorter the better, otherwise it is extremely painful to type programs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can always put the longer text into the LABEL of the variable.&amp;nbsp; For some strange reason they call the label DESCRIPTION in the XMLMAP file.&lt;/P&gt;
&lt;PRE&gt;&amp;lt;COLUMN name="Topic"&amp;gt;
  &amp;lt;PATH syntax="XPath"&amp;gt;/Responses/Response/QID2_TEXT_8cb70e63_1kek94049fwnTopicHierarchy1&amp;lt;/PATH&amp;gt;
  &amp;lt;TYPE&amp;gt;character&amp;lt;/TYPE&amp;gt;
  &amp;lt;DATATYPE&amp;gt;string&amp;lt;/DATATYPE&amp;gt;
  &amp;lt;LENGTH&amp;gt;32&amp;lt;/LENGTH&amp;gt;
  &amp;lt;DESCRIPTION&amp;gt;QID2_TEXT_8cb70e63_1kek94049fwnTopicHierarchy1&amp;lt;/DESCRIPTION&amp;gt;
&amp;lt;/COLUMN&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 01:17:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/913907#M44239</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-01T01:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: XML file - How to rename some variable based on the information found into the map file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/914017#M44241</link>
      <description>&lt;P&gt;we change the variable name manually but is there a way to do that with a SAS code&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 13:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/914017#M44241</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-01T13:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: XML file - How to rename some variable based on the information found into the map file</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/914027#M44242</link>
      <description>&lt;P&gt;It is not hard to read/write the XMLMAP file as a simple text file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename old 'xml.map';
filename new 'new_xml.map';
data _null_;
  infile old;
  file new;
  input;
  if left(_infile_)= '&amp;lt;COLUMN name="QID2_TEXT_8cb70e63_1kek94049fwn8"&amp;gt;' then
    put '&amp;lt;COLUMN name="Topic"&amp;gt;'
  ;
  else put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to get fancy the map file is itself an XML file.&amp;nbsp; So you could use the XMLV2 engine to read it into a dataset (or set of datasets).&amp;nbsp; Then manipulate the data in the way you want and write out a new map file.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 14:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/XML-file-How-to-rename-some-variable-based-on-the-information/m-p/914027#M44242</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-01T14:20:26Z</dc:date>
    </item>
  </channel>
</rss>

