From c1f1fcdebf9631419bb44a8e4dea8b4fa83cc554 Mon Sep 17 00:00:00 2001 From: allan Date: Mon, 9 Feb 2026 00:51:30 +0000 Subject: [PATCH] feat: new mx_createjob macro and associated test --- .gitpod.dockerfile | 6 -- .gitpod.yml | 27 ------ .npmignore | 1 - tests/x-platform/mx_createjob.test.sas | 27 ++++++ xplatform/mx_createjob.sas | 111 +++++++++++++++++++++++++ xplatform/mx_createwebservice.sas | 3 + 6 files changed, 141 insertions(+), 34 deletions(-) delete mode 100644 .gitpod.dockerfile delete mode 100644 .gitpod.yml create mode 100644 tests/x-platform/mx_createjob.test.sas create mode 100644 xplatform/mx_createjob.sas diff --git a/.gitpod.dockerfile b/.gitpod.dockerfile deleted file mode 100644 index 6b680a1..0000000 --- a/.gitpod.dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM gitpod/workspace-full - -RUN sudo apt-get update \ - && sudo apt-get install -y doxygen \ - && sudo apt-get install -y graphviz \ - && sudo rm -rf /var/lib/apt/lists/* diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index b825a64..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,27 +0,0 @@ -tasks: - - init: npm install -g npm - - command: npm i - - command: npm i -g @sasjs/cli - -image: - file: .gitpod.dockerfile -vscode: - extensions: - - sasjs.sasjs-for-vscode - -github: - prebuilds: - # enable for the master/default branch (defaults to true) - master: true - # enable for all branches in this repo (defaults to false) - branches: false - # enable for pull requests coming from this repo (defaults to true) - pullRequests: true - # enable for pull requests coming from forks (defaults to false) - pullRequestsFromForks: true - # add a "Review in Gitpod" button as a comment to pull requests (defaults to true) - addComment: true - # add a "Review in Gitpod" button to pull requests (defaults to false) - addBadge: false - # add a label once the prebuild is ready to pull requests (defaults to false) - addLabel: prebuilt-in-gitpod diff --git a/.npmignore b/.npmignore index 8ea87e4..c9a7666 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,5 @@ all.sas build.py -.gitpod* tests/ sasjs/ .github/ diff --git a/tests/x-platform/mx_createjob.test.sas b/tests/x-platform/mx_createjob.test.sas new file mode 100644 index 0000000..187a329 --- /dev/null +++ b/tests/x-platform/mx_createjob.test.sas @@ -0,0 +1,27 @@ +/** + @file + @brief Testing mx_createjob.sas macro + + Be sure to run %let mcTestAppLoc=/Public/temp/macrocore; when + running in Studio + +

SAS Macros

+ @li mx_createjob.sas + @li mp_assert.sas + +**/ + +filename ft15f001 temp; +parmcards4; + data example1; + set sashelp.class; + run; + %put Job executed successfully; +;;;; +%mx_createjob(path=&mcTestAppLoc/jobs,name=testjob,replace=YES) + +%mp_assert( + iftrue=(&syscc=0), + desc=No errors after job creation, + outds=work.test_results +) diff --git a/xplatform/mx_createjob.sas b/xplatform/mx_createjob.sas new file mode 100644 index 0000000..d4b10a5 --- /dev/null +++ b/xplatform/mx_createjob.sas @@ -0,0 +1,111 @@ +/** + @file mx_createjob.sas + @brief Create a job in SAS 9, Viya or SASjs + @details Creates a Stored Process in SAS 9, a Job Execution Service in SAS + Viya, or a Stored Program on SASjs Server - depending on the executing + environment. + +Usage: + + %* compile macros ; + filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas"; + %inc mc; + + %* write some code; + filename ft15f001 temp; + parmcards4; + data example1; + set sashelp.class; + run; + ;;;; + + %* create the job; + %mx_createjob(path=/Public/app/jobs,name=myjob,replace=YES) + +

SAS Macros

+ @li mf_getplatform.sas + @li mm_createstp.sas + @li ms_createfile.sas + @li mv_createjob.sas + + @param [in,out] path= The full folder path where the job will be created + @param [in,out] name= Job name. Avoid spaces. + @param [in] desc= The description of the job (optional) + @param [in] precode= Space separated list of filerefs, pointing to the code + that needs to be attached to the beginning of the job (optional) + @param [in] code= (ft15f001) Space seperated fileref(s) of the actual code to + be added + @param [in] replace= (YES) Select YES to replace any existing job in that + location + @param [in] mDebug= (0) set to 1 to show debug messages in the log + + @author Allan Bowe + +

Related Macros

+ @li mx_createjob.test.sas + @li mx_createwebservice.sas + +**/ + +%macro mx_createjob(path=HOME + ,name=initJob + ,precode= + ,code=ft15f001 + ,desc=This job was created by the mx_createjob macro + ,replace=YES + ,mdebug=0 +)/*/STORE SOURCE*/; + +%if &syscc ge 4 %then %do; + %put syscc=&syscc - &sysmacroname will not execute in this state; + %return; +%end; + +/* combine precode and code into a single file */ +%local tempref x fref freflist; +%let tempref=%mf_getuniquefileref(); +%local work tmpfile; +%let work=%sysfunc(pathname(work)); +%let tmpfile=&tempref..sas; +filename &tempref "&work/&tmpfile"; +%let freflist=&precode &code ; +%do x=1 %to %sysfunc(countw(&freflist)); + %let fref=%scan(&freflist,&x); + %put &sysmacroname: adding &fref; + data _null_; + file &tempref lrecl=3000 termstr=crlf mod; + infile &fref lrecl=3000; + input; + put _infile_; + run; +%end; + +%local platform; %let platform=%mf_getplatform(); +%if &platform=SASVIYA %then %do; + %if "&path"="HOME" %then %let path=/Users/&sysuserid/My Folder; + %mv_createjob(path=&path + ,name=&name + ,code=&tempref + ,desc=&desc + ,replace=&replace + ) +%end; +%else %if &platform=SASJS %then %do; + %if "&path"="HOME" %then %let path=/Users/&_sasjs_username/My Folder; + %ms_createfile(&path/&name..sas + ,inref=&tempref + ,mdebug=&mdebug + ) +%end; +%else %do; + %if "&path"="HOME" %then %let path=/User Folders/&_METAPERSON/My Folder; + %mm_createstp(stpname=&name + ,filename=&tmpfile + ,directory=&work + ,tree=&path + ,stpdesc=&desc + ,mDebug=&mdebug + ) +%end; +filename &tempref clear; +%mend mx_createjob; diff --git a/xplatform/mx_createwebservice.sas b/xplatform/mx_createwebservice.sas index 8e41978..ff2e1ac 100644 --- a/xplatform/mx_createwebservice.sas +++ b/xplatform/mx_createwebservice.sas @@ -48,6 +48,9 @@ Usage: @author Allan Bowe +

Related Macros

+ @li mx_createjob.sas + **/ %macro mx_createwebservice(path=HOME