sasjs / cli

Command line interface for creating, compiling, and building SAS® projects

Home Page:https://cli.sasjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Difference termprogram json and sas build output

mblauw-sas opened this issue · comments

Currently we do not have the possibility yet of authenticating to one of our SAS environments, so we run the .sas build output and run that in SAS Studio. We have a postbuild job included that creates .sas files from the job definitions.

Snippet from our sasjsconfig.json

"buildConfig": {
  "termProgram": "sasjs/admin/postbuild.sas"
},

And our target definition

{
  "name": "XX",
  "serverUrl": "https://XX",
  "serverType": "XX",
  "httpsAgentOptions": {
    "allowInsecureRequests": false
  },
  "appLoc": "XX",
  "jobConfig": {
    "jobFolders": [
      "XX",
          [...]
      "sasjs/admin"
    ],
    "initProgram": "_shared/jobs/jobinit.sas",
    "termProgram": "_shared/jobs/jobterm.sas",
    "macroVars": {
      "_apploc": "XX"
    }
  },
  "contextName": "SAS Job Execution compute context"
}

Our postbuild.sas program

/**
  @file
  @brief <Your brief here>
  <h4> SAS Macros </h4>
  @li m_sasjobinitwrite.sas
**/

%m_sasjobinitwrite(root=&_appLoc.);

Snippet of how this is included in the .sas build output

%global appLoc serverName;
%let compiled_apploc=XX;

%let appLoc=%sysfunc(coalescec(&appLoc,&compiled_apploc));

[...]

* BuildTerm start;
/**
  @file
  @brief <Your brief here>
  <h4> SAS Macros </h4>
  @li m_sasjobinitwrite.sas
**/

%m_sasjobinitwrite(root=&_appLoc.);
* BuildTerm end;

Snippet of how this is included in the .json build output

"name": "admin",
"type": "folder",
"members": [
 {
  "name": "postbuild",
  "type": "service",
  "code": "* Job Variables start;\n\n%let _apploc= XXX
      [...]
   %m_sasjobinitwrite(root=&_appLoc.);
      [...]
 }
]

It seems that using sasjs deploy, sasjs triggers the deployed job on the server. This deployed job is aware of the &_appLoc variable. However, the .sas job output seems to use the "open code" deployscript, which is only aware of &appLoc and not of &_appLoc. Thus resulting in an error.

Thanks @mblauw-sas! To summarise the conversation we had:

  • Macro vars for the build .sas program must be specified in the buildConfig
  • the termProgram only runs in the .sas program, not in the sasjs deploy (JSON on Viya) by default, that requires a deployScript
  • The workaround in your case was to use appLoc instead of _appLoc

Good luck with the project, and keep in touch!