Published on :
Administration INTERNAL_CREATION

Re-associating File Objects via SAS 9 Metadata

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
This program was written to resolve job scheduling issues following a migration that resulted in path changes. It connects to the metadata server (OMR), verifies the existence of directory objects (old and new) via their IDs, and uses metadata interface functions (`metadata_resolve`, `metadata_getnasn`, `metadata_setassn`) to move file associations. IMPORTANT NOTE: This code uses the syntax and mechanisms specific to the SAS© 9 Metadata Server (`options metaserver`, `omsobj:Directory`). It is not natively compatible with the microservices architecture (Folders/Files Services) of SAS© Viya 4 without major adaptation or connection to a remote SAS© 9 server.
Data Analysis

Type : INTERNAL_CREATION


Direct manipulation of system metadata (no business data).

1 Code Block
OPTIONS
Explanation :
Configuration of the connection to the SAS 9 metadata server (Host, Port, User, Repo).
Copied!
1options
2 metaserver='meta.demo.sas.com'
3 metaport=8561
4 metauser='sasadm @saspw'
5 metapass='password'
6 metarepository='Foundation';
2 Code Block
DATA STEP
Explanation :
Main _NULL_ Data step which: 1. Checks for the existence of directory objects via `metadata_resolve`. 2. Retrieves URIs. 3. Counts files associated with the old directory. 4. Loops through each file to replace the association with the new directory via `metadata_setassn`.
Copied!
1DATA _null_;
2 /* Set the old and new IDs. */
3 %let olddir = 'A5STBUB8.B6000002';
4 %let newdir = 'A5STBUB8.B6000002';
5 /* ... (logique de résolution et boucle) ... */
6 rc=metadata_resolve("omsobj:Directory?id=&olddir",type,id);
7 /* ... */
8 file_count=metadata_getnasn(old_uri,"Files",1,file_uri);
9 IF file_count > 0 THEN DO i=1 to file_count;
10 /* ... */
11 rc=metadata_setassn(file_uri,"Directories","REPLACE",new_uri);
12 END;
13RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 24JUL2018