Migrating EG Projects through Dev-Test-Prod

1

I wanted to share a trick/technique with you all regarding making it easier to migrate EG projects from one environment to another. The issue is that there are often occasions where it is necessary to code file paths in an EG project (just like in any other SAS program) and those file paths will typically need to be updated when the code is moved.

It occurred to me that if it were possible to get the default file path in EG, it would be possible to specify any file references to be relative to that location, thus minimizing any changes needed when migrating code. With the help of Eli (not sure of his last name) and Bubba Talley of SAS Technical Support (who provided the code sample below), it is possible to do just that.

The basics of the techniques follows. Consider a dev/test/prod environment where the file paths might be:
/projects/dev
/projects/test
/projects/prod

Or perhaps something like:
/serverA/projects/dev
/serverB/projects/test
/prodServer/projects
And under these directories you might have directories like wdata, staging, storedprocesses, and so on.

So you will want EG in each environment to point to the appropriate directory. Assuming there is a separate Metadata Server for each environment you can accomplish this by going into SMC for each environment and:

  1. Expand Server Manager
  2. Expand SASMain
  3. Expand SASMain - Workspace Server
  4. Right click on SASMain - Workspace Server (at the bottom of the tree)
  5. Select Options
  6. Select Advanced Options
  7. Select File Navigation Tab
  8. Select Path and fill in the right value for the current environment (e.g., Dev or Test or Prod or whatever)

You have now specified a separate default directory path for each environment.

Next, include the following code in your project (it could also perhaps be added to the autoexec for the Workspace Server - that is something yet to be tested) to get the value of the default file path and create a macro variable:

     %let root = ;
     data _null_;
          length obj id navpath $256 type $32;
          call missing(id,type,navpath);
          obj="omsobj:Property?Property[@PropertyName='FileNavigation']
AssociatedObject/ServerComponent[@Name contains 'Workspace']
UsedbyComponents/LogicalServer/UsedByComponents/ServerContext[@Name='" || "&_SASSERVERNAME." || "']]";
          rc=metadata_resolve(obj,type,id);
          if (rc > 0) then do;
               rc2=metadata_getattr(obj,"DefaultValue",NavPath);
               call symput('Root',trim(NavPath));
          end;
          else put 'ERROR: No Property found ' obj=;
     run;
%put NOTE: Environment Root is: &root..;

And your programs can now define libnames/filenames using statements like:
libname wdata "&root;/wdata;

When the projects are moved, there is no need to edit anything to change file paths.
Note the user of the macro variable _SASSERVERNAME in the above code. This addresses the fact that there may be more than one Application Server with a Workspace defined to the repository, for example you might have:

  • SASApp - Workspace Server
  • SASMain - Workspace Server.

So the code uses the _SASSERVERNAME macro variable which contains the name of the Application Server (ServerContext) such as SASMain. Unfortunately there is no corresponding macro variable that can be used if the name of the Workspace Server is changed to something other than Workspace. However, when implementing an application for customer, this is something that can probably be dealt with. We could perhaps also use such techniques to get info regarding other servers (e.g., the Stored Process Server).

Provided to sas-BIogsource by Don Henderson. Thanks!

Share

About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

1 Comment

  1. Frank Poppe on

    Hi Angela,
    Although looking form something else, the search page directed me to this blog post.

    Reading this, I was wondering if that Property gives the same value you get when doing
    libname defPath '' ;
    %let defPath = %sysfunc ( pathname ( defPath ) ) ;

    In general I always try to avoid absolute file paths in favor of relative paths. If it is necessary to 'move up' first with respect to the default path I use a syntax like filename mydata '../data' .

Back to Top