<?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: Updating SAS metadata server programatically with new stored process locations. in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/Updating-SAS-metadata-server-programatically-with-new-stored/m-p/585143#M17074</link>
    <description>&lt;P&gt;Use the attached macro and the program below.&lt;/P&gt;
&lt;P&gt;You need to add the old locations to the data step that contains the SELECT-WHEN statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please make a backup of your metadata&amp;nbsp;&lt;STRONG&gt;before&lt;/STRONG&gt; running the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Extract information about Stored Processes in Metadata */
%meta_extractstoredprocesses(Table=StoredProcesses);

/* Extract information about Directories. A directory can be used by multiple STP's only select one unique. */
proc sql noprint;
  create table locations as
    select distinct
      dir_uri,
      SourceCodeDir
    from StoredProcesses 
    where SourceCodeDir ne '&amp;lt;In Metadata&amp;gt;'
  ;
quit;

/* Update the directories to new locations */
data newlocations;
  set locations;
  UpdateDirectory = 0;
  select (upcase(SourceCodeDir));
    /* Only for testing, do not use in production */
    when ('C:\PROGRAM FILES\SASHOME\SASFOUNDATION\9.4\INTTECH\SAMPLE2') 
      do;
        SourceCodeDir = 'C:\Program Files\SASHome\SASFoundation\9.4\inttech\sample';
        UpdateDirectory = 1;
      end;
    otherwise ;
  end;
  if UpdateDirectory then do;
    putlog 'Updating Directory';
    rc=metadata_getnobj(dir_uri,1,tran_uri);
    put rc=;
    rc=metadata_setattr(dir_uri,"DirectoryName",SourcecodeDir);
    put rc=;
  end;
run;

/* Extract information about Stored Processes in Metadata and verify the Directories were updated. */
%meta_extractstoredprocesses(Table=StoredProcesses);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 30 Aug 2019 08:17:39 GMT</pubDate>
    <dc:creator>MichaelLarsen</dc:creator>
    <dc:date>2019-08-30T08:17:39Z</dc:date>
    <item>
      <title>Updating SAS metadata server programatically with new stored process locations.</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Updating-SAS-metadata-server-programatically-with-new-stored/m-p/584989#M17071</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;We are in the process of migrating SAS from windows server 2008 to WIndows server 2016.&lt;BR /&gt;The metadata was migrated.&lt;BR /&gt;However the path for store process source code on the new servers is different than in the old server.&lt;BR /&gt;The metadata has the old locations.&lt;BR /&gt;Using the code here (&lt;A href="https://blogs.sas.com/content/sastraining/2012/06/11/locating_storedprocess_code/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2012/06/11/locating_storedprocess_code/&lt;/A&gt;&amp;nbsp;method 3) obtained the stored process details.&lt;BR /&gt;Now want to update the&amp;nbsp; metadata with new source code locations using sas code.&lt;BR /&gt;Is there a way to do it?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 16:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Updating-SAS-metadata-server-programatically-with-new-stored/m-p/584989#M17071</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2019-08-29T16:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Updating SAS metadata server programatically with new stored process locations.</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Updating-SAS-metadata-server-programatically-with-new-stored/m-p/585143#M17074</link>
      <description>&lt;P&gt;Use the attached macro and the program below.&lt;/P&gt;
&lt;P&gt;You need to add the old locations to the data step that contains the SELECT-WHEN statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please make a backup of your metadata&amp;nbsp;&lt;STRONG&gt;before&lt;/STRONG&gt; running the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Extract information about Stored Processes in Metadata */
%meta_extractstoredprocesses(Table=StoredProcesses);

/* Extract information about Directories. A directory can be used by multiple STP's only select one unique. */
proc sql noprint;
  create table locations as
    select distinct
      dir_uri,
      SourceCodeDir
    from StoredProcesses 
    where SourceCodeDir ne '&amp;lt;In Metadata&amp;gt;'
  ;
quit;

/* Update the directories to new locations */
data newlocations;
  set locations;
  UpdateDirectory = 0;
  select (upcase(SourceCodeDir));
    /* Only for testing, do not use in production */
    when ('C:\PROGRAM FILES\SASHOME\SASFOUNDATION\9.4\INTTECH\SAMPLE2') 
      do;
        SourceCodeDir = 'C:\Program Files\SASHome\SASFoundation\9.4\inttech\sample';
        UpdateDirectory = 1;
      end;
    otherwise ;
  end;
  if UpdateDirectory then do;
    putlog 'Updating Directory';
    rc=metadata_getnobj(dir_uri,1,tran_uri);
    put rc=;
    rc=metadata_setattr(dir_uri,"DirectoryName",SourcecodeDir);
    put rc=;
  end;
run;

/* Extract information about Stored Processes in Metadata and verify the Directories were updated. */
%meta_extractstoredprocesses(Table=StoredProcesses);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 08:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Updating-SAS-metadata-server-programatically-with-new-stored/m-p/585143#M17074</guid>
      <dc:creator>MichaelLarsen</dc:creator>
      <dc:date>2019-08-30T08:17:39Z</dc:date>
    </item>
  </channel>
</rss>

