1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-07 17:40:05 +00:00

Compare commits

...

15 Commits

Author SHA1 Message Date
Allan Bowe
a88689428f fix: updating cycjimmy/semantic-release-action to v3 2023-01-25 12:56:38 +00:00
munja
8843fa8bfc fix: adding nrstr() wrapper in mm_adduser2group 2023-01-25 12:53:10 +00:00
Allan Bowe
22d046cf5c Merge pull request #324 from sasjs/servertestfixes
fix: updating ms_runstp and ms_testservice macros to cater for latest…
2023-01-06 13:15:11 +01:00
munja
29e3eb34aa fix: updating ms_runstp and ms_testservice macros to cater for latest response JSON formats in sasjs/server 2023-01-06 12:13:36 +00:00
munja
1af52a6683 fix: adding des= macro option to mf_abort 2023-01-02 11:26:21 +00:00
munja
fc0c96dd94 chore: merge 2022-12-30 12:41:08 +00:00
munja
b9c4882553 fix: linting issues 2022-12-30 12:38:34 +00:00
Allan Bowe
011b2b185c chore: removing broken badges in README 2022-12-28 20:25:05 +00:00
Allan Bowe
dbc23550ac Merge pull request #323 from sasjs/ms_getgroups
fix: increasing desc length to 256 in ms_getgroups
2022-12-28 21:21:35 +01:00
munja
8910840ccc fix: increasing desc length to 256 in ms_getgroups 2022-12-28 20:17:08 +00:00
Allan Bowe
4ef571032d Merge pull request #322 from sasjs/upds
Upds
2022-12-14 14:21:20 +01:00
Allan Bowe
e01cd8cd16 Merge branch 'main' into upds 2022-12-14 14:20:51 +01:00
munja
00628ec78a chore: updating lint settings, some line ending issues, and a sasjsconfig apploc fix 2022-12-14 14:19:28 +01:00
munja
f4e6a487f3 fix: removing redundant param in mS/M_webout macros 2022-12-14 14:17:06 +01:00
Allan Bowe
b7afecdf81 fix: escaping syswarningtext and syserrortext in mp_abort 2022-12-04 21:14:10 +00:00
25 changed files with 1007 additions and 539 deletions

View File

@@ -15,7 +15,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
env: env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -1,13 +1,14 @@
{ {
"noTrailingSpaces": true, "noTrailingSpaces": true,
"noEncodedPasswords": true, "noEncodedPasswords": true,
"hasDoxygenHeader": true, "hasDoxygenHeader": true,
"hasMacroNameInMend": true, "hasMacroNameInMend": true,
"hasMacroParentheses": true, "hasMacroParentheses": true,
"noNestedMacros": false, "noGremlins": true,
"noSpacesInFileNames": true, "noNestedMacros": false,
"maxLineLength": 300, "noSpacesInFileNames": true,
"lowerCaseFileNames": true, "maxLineLength": 300,
"noTabIndentation": true, "lowerCaseFileNames": true,
"indentationMultiple": 2 "noTabs": true,
} "indentationMultiple": 2
}

View File

@@ -6,5 +6,7 @@
"editor.rulers": [ "editor.rulers": [
80 80
], ],
"files.trimTrailingWhitespace": true "files.trimTrailingWhitespace": true,
"sasjs-for-vscode.target": "docsonly",
"sasjs-for-vscode.isLocal": true
} }

View File

@@ -2,8 +2,6 @@
[![npm package][npm-image]][npm-url] [![npm package][npm-image]][npm-url]
[![Github Workflow][githubworkflow-image]][githubworkflow-url] [![Github Workflow][githubworkflow-image]][githubworkflow-url]
![npm](https://img.shields.io/npm/dt/@sasjs/core) ![npm](https://img.shields.io/npm/dt/@sasjs/core)
![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@sasjs/core)
[![License](https://img.shields.io/apm/l/atomic-design-ui.svg)](/LICENSE)
![GitHub top language](https://img.shields.io/github/languages/top/sasjs/core) ![GitHub top language](https://img.shields.io/github/languages/top/sasjs/core)
[![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/sasjs/core)](https://github.com/sasjs/core/issues?q=is%3Aissue+is%3Aclosed) [![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/sasjs/core)](https://github.com/sasjs/core/issues?q=is%3Aissue+is%3Aclosed)
[![GitHub issues](https://img.shields.io/github/issues-raw/sasjs/core)](https://github.com/sasjs/core/issues) [![GitHub issues](https://img.shields.io/github/issues-raw/sasjs/core)](https://github.com/sasjs/core/issues)

134
all.sas
View File

@@ -30,7 +30,7 @@ options noquotelenmax;
**/ **/
%macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1) %macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1)
)/*/STORE SOURCE*/; )/des='ungraceful abort' /*STORE SOURCE*/;
%if not(%eval(%unquote(&iftrue))) %then %return; %if not(%eval(%unquote(&iftrue))) %then %return;
@@ -42,7 +42,8 @@ options noquotelenmax;
%mend mf_abort; %mend mf_abort;
/** @endcond *//** /** @endcond */
/**
@file @file
@brief de-duplicates a macro string @brief de-duplicates a macro string
@details Removes all duplicates from a string of words. A delimeter can be @details Removes all duplicates from a string of words. A delimeter can be
@@ -247,7 +248,8 @@ options noquotelenmax;
0 0
%end; %end;
%mend mf_existfileref;/** %mend mf_existfileref;
/**
@file @file
@brief Checks if a function exists @brief Checks if a function exists
@details Returns 1 if the function exists, else 0. Note that this function @details Returns 1 if the function exists, else 0. Note that this function
@@ -2542,15 +2544,51 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
_PROGRAM=quote(trim(resolve(symget('_PROGRAM')))); _PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
put ',"_PROGRAM" : ' _PROGRAM ; put ',"_PROGRAM" : ' _PROGRAM ;
put ",""SYSCC"" : ""&syscc"" "; put ",""SYSCC"" : ""&syscc"" ";
syserrortext=cats('"',tranwrd(symget('syserrortext'),'"','\"'),'"'); syserrortext=cats(symget('syserrortext'));
put ",""SYSERRORTEXT"" : " syserrortext; if findc(syserrortext,'"\'!!'0A0D09000E0F010210111A'x) then do;
syserrortext='"'!!trim(
prxchange('s/"/\\"/',-1, /* double quote */
prxchange('s/\x0A/\n/',-1, /* new line */
prxchange('s/\x0D/\r/',-1, /* carriage return */
prxchange('s/\x09/\\t/',-1, /* tab */
prxchange('s/\x00/\\u0000/',-1, /* NUL */
prxchange('s/\x0E/\\u000E/',-1, /* SS */
prxchange('s/\x0F/\\u000F/',-1, /* SF */
prxchange('s/\x01/\\u0001/',-1, /* SOH */
prxchange('s/\x02/\\u0002/',-1, /* STX */
prxchange('s/\x10/\\u0010/',-1, /* DLE */
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
prxchange('s/\\/\\\\/',-1,syserrortext)
)))))))))))))!!'"';
end;
else syserrortext=cats('"',syserrortext,'"');
put ',"SYSERRORTEXT" : ' syserrortext;
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
put ",""SYSSCPL"" : ""&sysscpl"" "; put ",""SYSSCPL"" : ""&sysscpl"" ";
put ",""SYSSITE"" : ""&syssite"" "; put ",""SYSSITE"" : ""&syssite"" ";
sysvlong=quote(trim(symget('sysvlong'))); sysvlong=quote(trim(symget('sysvlong')));
put ',"SYSVLONG" : ' sysvlong; put ',"SYSVLONG" : ' sysvlong;
syswarningtext=cats('"',tranwrd(symget('syswarningtext'),'"','\"'),'"'); syswarningtext=cats(symget('syswarningtext'));
if findc(syswarningtext,'"\'!!'0A0D09000E0F010210111A'x) then do;
syswarningtext='"'!!trim(
prxchange('s/"/\\"/',-1, /* double quote */
prxchange('s/\x0A/\n/',-1, /* new line */
prxchange('s/\x0D/\r/',-1, /* carriage return */
prxchange('s/\x09/\\t/',-1, /* tab */
prxchange('s/\x00/\\u0000/',-1, /* NUL */
prxchange('s/\x0E/\\u000E/',-1, /* SS */
prxchange('s/\x0F/\\u000F/',-1, /* SF */
prxchange('s/\x01/\\u0001/',-1, /* SOH */
prxchange('s/\x02/\\u0002/',-1, /* STX */
prxchange('s/\x10/\\u0010/',-1, /* DLE */
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
prxchange('s/\\/\\\\/',-1,syswarningtext)
)))))))))))))!!'"';
end;
else syswarningtext=cats('"',syswarningtext,'"');
put ",""SYSWARNINGTEXT"" : " syswarningtext; put ",""SYSWARNINGTEXT"" : " syswarningtext;
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" '; put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
put "}" ; put "}" ;
@@ -14023,7 +14061,8 @@ run;
filename __us2grp temp; filename __us2grp temp;
proc metadata in= "<UpdateMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata> proc metadata in= "<UpdateMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata>
<Person Id='&uuri'><IdentityGroups><IdentityGroup ObjRef='&guri' /> <Person Id='%nrstr(&uuri)'>
<IdentityGroups><IdentityGroup ObjRef='%nrstr(&guri)' />
</IdentityGroups></Person></Metadata> </IdentityGroups></Person></Metadata>
<NS>SAS</NS><Flags>268435456</Flags></UpdateMetadata>" <NS>SAS</NS><Flags>268435456</Flags></UpdateMetadata>"
out=__us2grp verbose; out=__us2grp verbose;
@@ -14040,7 +14079,8 @@ run;
filename __us2grp clear; filename __us2grp clear;
%mend mm_adduser2group;/** %mend mm_adduser2group;
/**
@file @file
@brief Assigns library directly using details from metadata @brief Assigns library directly using details from metadata
@details Queries metadata to get the libname definition then allocates the @details Queries metadata to get the libname definition then allocates the
@@ -16403,7 +16443,7 @@ data _null_;
put ' put " ""&wt"" : {"; '; put ' put " ""&wt"" : {"; ';
put ' put ''"nlobs":'' nlobs; '; put ' put ''"nlobs":'' nlobs; ';
put ' put '',"nvars":'' nvars; '; put ' put '',"nvars":'' nvars; ';
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10 '; put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y ';
put ' ,maxobs=&workobs '; put ' ,maxobs=&workobs ';
put ' ) '; put ' ) ';
put ' data _null_; file _sjsref mod encoding=''utf-8''; '; put ' data _null_; file _sjsref mod encoding=''utf-8''; ';
@@ -20085,7 +20125,7 @@ run;
put " ""&wt"" : {"; put " ""&wt"" : {";
put '"nlobs":' nlobs; put '"nlobs":' nlobs;
put ',"nvars":' nvars; put ',"nvars":' nvars;
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10 %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y
,maxobs=&workobs ,maxobs=&workobs
) )
data _null_; file _sjsref mod encoding='utf-8'; data _null_; file _sjsref mod encoding='utf-8';
@@ -21489,7 +21529,7 @@ data _null_;
put ' put " ""&wt"" : {"; '; put ' put " ""&wt"" : {"; ';
put ' put ''"nlobs":'' nlobs; '; put ' put ''"nlobs":'' nlobs; ';
put ' put '',"nvars":'' nvars; '; put ' put '',"nvars":'' nvars; ';
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10 '; put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y ';
put ' ,maxobs=&workobs '; put ' ,maxobs=&workobs ';
put ' ) '; put ' ) ';
put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; '; put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';
@@ -21756,7 +21796,7 @@ filename &headref clear;
@param [in] uid= (0) Provide the userid on which to filter @param [in] uid= (0) Provide the userid on which to filter
@param [out] outds= (work.ms_getgroups) This output dataset will contain the @param [out] outds= (work.ms_getgroups) This output dataset will contain the
list of groups. Format: list of groups. Format:
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.| |NAME:$32.|DESCRIPTION:$256.|GROUPID:best.|
|---|---|---| |---|---|---|
|`SomeGroup `|`A group `|`1`| |`SomeGroup `|`A group `|`1`|
|`Another Group`|`this is a different group`|`2`| |`Another Group`|`this is a different group`|`2`|
@@ -21792,7 +21832,7 @@ filename &headref clear;
%if %sysget(MODE)=desktop %then %do; %if %sysget(MODE)=desktop %then %do;
/* groups api does not exist in desktop mode */ /* groups api does not exist in desktop mode */
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $256. GROUPID 8;
name="&sysuserid"; name="&sysuserid";
description="&sysuserid (group - desktop mode)"; description="&sysuserid (group - desktop mode)";
groupid=1; groupid=1;
@@ -21848,7 +21888,7 @@ libname &libref JSON fileref=&fref1;
%if "&user"="0" and "&uid"="0" %then %do; %if "&user"="0" and "&uid"="0" %then %do;
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $256. GROUPID 8;
if _n_=1 then call missing(of _all_); if _n_=1 then call missing(of _all_);
set &libref..root; set &libref..root;
drop ordinal_root; drop ordinal_root;
@@ -21856,7 +21896,7 @@ libname &libref JSON fileref=&fref1;
%end; %end;
%else %do; %else %do;
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $256. GROUPID 8;
if _n_=1 then call missing(of _all_); if _n_=1 then call missing(of _all_);
set &libref..groups; set &libref..groups;
drop ordinal_:; drop ordinal_:;
@@ -22068,8 +22108,9 @@ options &optval;
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mf_getuniquefileref.sas @li mf_getuniquefileref.sas
@li mf_getuniquelibref.sas @li mf_getuniquename.sas
@li mp_abort.sas @li mp_abort.sas
@li mp_chop.sas
**/ **/
@@ -22182,7 +22223,10 @@ run;
run; run;
%end; %end;
filename &outref temp lrecl=32767; %local resp_path;
%let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
filename &outref "&resp_path" lrecl=32767;
/* prepare request*/ /* prepare request*/
proc http method='POST' headerin=&authref in=&mainref out=&outref proc http method='POST' headerin=&authref in=&mainref out=&outref
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131"; url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
@@ -22190,6 +22234,7 @@ proc http method='POST' headerin=&authref in=&mainref out=&outref
debug level=2; debug level=2;
%end; %end;
run; run;
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201) %if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
or &mdebug=1 or &mdebug=1
%then %do; %then %do;
@@ -22205,11 +22250,22 @@ or &mdebug=1
options &optval; options &optval;
%if &outlogds ne _null_ or &mdebug=1 %then %do; %if &outlogds ne _null_ or &mdebug=1 %then %do;
%local dumplib; %local matchstr chopout;
%let dumplib=%mf_getuniquelibref(); %let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
libname &dumplib json fileref=&outref; %let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
%mp_chop("&resp_path"
,matchvar=matchstr
,keep=LAST
,matchpoint=END
,outfile="&chopout"
,mdebug=&mdebug
)
data &outlogds; data &outlogds;
set &dumplib..log; infile "&chopout" lrecl=2000;
length line $2000;
line=_infile_;
%if &mdebug=1 %then %do; %if &mdebug=1 %then %do;
putlog line=; putlog line=;
%end; %end;
@@ -22336,50 +22392,38 @@ run;
) )
/* SASjs services have the _webout embedded in wrapper JSON */ /* chop out JSON section */
/* Files can also be very large - so use a dedicated macro to chop it out */ %local matchstr chopout;
%local matchstr1 matchstr2 ; %let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
%let matchstr1={"status":"success","_webout":{; %let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
%let matchstr2=},"log":[{;
%let chopout1=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop1);
%let chopout2=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop2);
%mp_chop("%sysfunc(pathname(&fref1,F))" %mp_chop("%sysfunc(pathname(&fref1,F))"
,matchvar=matchstr1 ,matchvar=matchstr
,keep=LAST
,matchpoint=END
,offset=-1
,outfile="&chopout1"
,mdebug=&mdebug
)
%mp_chop("&chopout1"
,matchvar=matchstr2
,keep=FIRST ,keep=FIRST
,matchpoint=START ,matchpoint=START
,offset=1 ,offset=-1
,outfile="&chopout2" ,outfile="&chopout"
,mdebug=&mdebug ,mdebug=&mdebug
) )
%if &outlib ne 0 %then %do; %if &outlib ne 0 %then %do;
libname &outlib json "&chopout2"; libname &outlib json "&chopout";
%end; %end;
%if &outref ne 0 %then %do; %if &outref ne 0 %then %do;
filename &outref "&chopout2"; filename &outref "&chopout";
%end; %end;
%if &mdebug=0 %then %do; %if &mdebug=0 %then %do;
filename &webref clear; filename &webref clear;
filename &fref1 clear; filename &fref1 clear;
filename &fref2 clear;
%end; %end;
%else %do; %else %do;
%put &sysmacroname exit vars:; %put &sysmacroname exit vars:;
%put _local_; %put _local_;
%end; %end;
%mend ms_testservice;/** %mend ms_testservice;
/**
@file @file
@brief Send data to/from sasjs/server @brief Send data to/from sasjs/server
@details This macro should be added to the start of each web service, @details This macro should be added to the start of each web service,
@@ -22522,7 +22566,7 @@ run;
put " ""&wt"" : {"; put " ""&wt"" : {";
put '"nlobs":' nlobs; put '"nlobs":' nlobs;
put ',"nvars":' nvars; put ',"nvars":' nvars;
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10 %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
,maxobs=&workobs ,maxobs=&workobs
) )
data _null_; file &fref mod encoding='utf-8' termstr=lf; data _null_; file &fref mod encoding='utf-8' termstr=lf;

View File

@@ -12,7 +12,7 @@
**/ **/
%macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1) %macro mf_abort(mac=mf_abort.sas, msg=, iftrue=%str(1=1)
)/*/STORE SOURCE*/; )/des='ungraceful abort' /*STORE SOURCE*/;
%if not(%eval(%unquote(&iftrue))) %then %return; %if not(%eval(%unquote(&iftrue))) %then %return;
@@ -24,4 +24,4 @@
%mend mf_abort; %mend mf_abort;
/** @endcond */ /** @endcond */

View File

@@ -30,4 +30,4 @@
0 0
%end; %end;
%mend mf_existfileref; %mend mf_existfileref;

View File

@@ -225,15 +225,51 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
_PROGRAM=quote(trim(resolve(symget('_PROGRAM')))); _PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
put ',"_PROGRAM" : ' _PROGRAM ; put ',"_PROGRAM" : ' _PROGRAM ;
put ",""SYSCC"" : ""&syscc"" "; put ",""SYSCC"" : ""&syscc"" ";
syserrortext=cats('"',tranwrd(symget('syserrortext'),'"','\"'),'"'); syserrortext=cats(symget('syserrortext'));
put ",""SYSERRORTEXT"" : " syserrortext; if findc(syserrortext,'"\'!!'0A0D09000E0F010210111A'x) then do;
syserrortext='"'!!trim(
prxchange('s/"/\\"/',-1, /* double quote */
prxchange('s/\x0A/\n/',-1, /* new line */
prxchange('s/\x0D/\r/',-1, /* carriage return */
prxchange('s/\x09/\\t/',-1, /* tab */
prxchange('s/\x00/\\u0000/',-1, /* NUL */
prxchange('s/\x0E/\\u000E/',-1, /* SS */
prxchange('s/\x0F/\\u000F/',-1, /* SF */
prxchange('s/\x01/\\u0001/',-1, /* SOH */
prxchange('s/\x02/\\u0002/',-1, /* STX */
prxchange('s/\x10/\\u0010/',-1, /* DLE */
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
prxchange('s/\\/\\\\/',-1,syserrortext)
)))))))))))))!!'"';
end;
else syserrortext=cats('"',syserrortext,'"');
put ',"SYSERRORTEXT" : ' syserrortext;
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
put ",""SYSSCPL"" : ""&sysscpl"" "; put ",""SYSSCPL"" : ""&sysscpl"" ";
put ",""SYSSITE"" : ""&syssite"" "; put ",""SYSSITE"" : ""&syssite"" ";
sysvlong=quote(trim(symget('sysvlong'))); sysvlong=quote(trim(symget('sysvlong')));
put ',"SYSVLONG" : ' sysvlong; put ',"SYSVLONG" : ' sysvlong;
syswarningtext=cats('"',tranwrd(symget('syswarningtext'),'"','\"'),'"'); syswarningtext=cats(symget('syswarningtext'));
if findc(syswarningtext,'"\'!!'0A0D09000E0F010210111A'x) then do;
syswarningtext='"'!!trim(
prxchange('s/"/\\"/',-1, /* double quote */
prxchange('s/\x0A/\n/',-1, /* new line */
prxchange('s/\x0D/\r/',-1, /* carriage return */
prxchange('s/\x09/\\t/',-1, /* tab */
prxchange('s/\x00/\\u0000/',-1, /* NUL */
prxchange('s/\x0E/\\u000E/',-1, /* SS */
prxchange('s/\x0F/\\u000F/',-1, /* SF */
prxchange('s/\x01/\\u0001/',-1, /* SOH */
prxchange('s/\x02/\\u0002/',-1, /* STX */
prxchange('s/\x10/\\u0010/',-1, /* DLE */
prxchange('s/\x11/\\u0011/',-1, /* DC1 */
prxchange('s/\x1A/\\u001A/',-1, /* SUB */
prxchange('s/\\/\\\\/',-1,syswarningtext)
)))))))))))))!!'"';
end;
else syswarningtext=cats('"',syswarningtext,'"');
put ",""SYSWARNINGTEXT"" : " syswarningtext; put ",""SYSWARNINGTEXT"" : " syswarningtext;
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" '; put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
put "}" ; put "}" ;

View File

@@ -81,7 +81,8 @@ run;
filename __us2grp temp; filename __us2grp temp;
proc metadata in= "<UpdateMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata> proc metadata in= "<UpdateMetadata><Reposid>$METAREPOSITORY</Reposid><Metadata>
<Person Id='&uuri'><IdentityGroups><IdentityGroup ObjRef='&guri' /> <Person Id='%nrstr(&uuri)'>
<IdentityGroups><IdentityGroup ObjRef='%nrstr(&guri)' />
</IdentityGroups></Person></Metadata> </IdentityGroups></Person></Metadata>
<NS>SAS</NS><Flags>268435456</Flags></UpdateMetadata>" <NS>SAS</NS><Flags>268435456</Flags></UpdateMetadata>"
out=__us2grp verbose; out=__us2grp verbose;
@@ -98,4 +99,4 @@ run;
filename __us2grp clear; filename __us2grp clear;
%mend mm_adduser2group; %mend mm_adduser2group;

View File

@@ -546,7 +546,7 @@ data _null_;
put ' put " ""&wt"" : {"; '; put ' put " ""&wt"" : {"; ';
put ' put ''"nlobs":'' nlobs; '; put ' put ''"nlobs":'' nlobs; ';
put ' put '',"nvars":'' nvars; '; put ' put '',"nvars":'' nvars; ';
put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10 '; put ' %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y ';
put ' ,maxobs=&workobs '; put ' ,maxobs=&workobs ';
put ' ) '; put ' ) ';
put ' data _null_; file _sjsref mod encoding=''utf-8''; '; put ' data _null_; file _sjsref mod encoding=''utf-8''; ';

View File

@@ -150,7 +150,7 @@
put " ""&wt"" : {"; put " ""&wt"" : {";
put '"nlobs":' nlobs; put '"nlobs":' nlobs;
put ',"nvars":' nvars; put ',"nvars":' nvars;
%mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y,maxobs=10 %mp_jsonout(OBJ,&wt,jref=_sjsref,dslabel=first10rows,showmeta=Y
,maxobs=&workobs ,maxobs=&workobs
) )
data _null_; file _sjsref mod encoding='utf-8'; data _null_; file _sjsref mod encoding='utf-8';

668
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,6 @@
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true" "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
}, },
"devDependencies": { "devDependencies": {
"@sasjs/cli": "3.13.0" "@sasjs/cli": "3.24.0"
} }
} }

View File

@@ -85,7 +85,7 @@
{ {
"name": "docsonly", "name": "docsonly",
"serverType": "SASJS", "serverType": "SASJS",
"appLoc": "dummy", "appLoc": "/dummy",
"macroFolders": [ "macroFolders": [
"meta", "meta",
"metax", "metax",

View File

@@ -1,224 +1,224 @@
/** /**
@file @file
@brief Deploy repo as a SAS PACKAGES module @brief Deploy repo as a SAS PACKAGES module
@details After every release, this program is executed to update the SASPAC @details After every release, this program is executed to update the SASPAC
repo with the latest macros (and same version number). repo with the latest macros (and same version number).
The program is first compiled using sasjs compile, then executed using The program is first compiled using sasjs compile, then executed using
sasjs run. sasjs run.
Requires the server to have SSH keys. Requires the server to have SSH keys.
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mp_gitadd.sas @li mp_gitadd.sas
@li mp_gitreleaseinfo.sas @li mp_gitreleaseinfo.sas
@li mp_gitstatus.sas @li mp_gitstatus.sas
**/ **/
/* get package version */ /* get package version */
%mp_gitreleaseinfo(GITHUB,sasjs/core,outlib=splib) %mp_gitreleaseinfo(GITHUB,sasjs/core,outlib=splib)
data _null_; data _null_;
set splib.root; set splib.root;
call symputx('version',substr(TAG_NAME,2)); call symputx('version',substr(TAG_NAME,2));
run; run;
/* clone the source repo */ /* clone the source repo */
%let dir = %sysfunc(pathname(work))/core; %let dir = %sysfunc(pathname(work))/core;
%put source clone rc=%sysfunc(GITFN_CLONE(https://github.com/sasjs/core,&dir)); %put source clone rc=%sysfunc(GITFN_CLONE(https://github.com/sasjs/core,&dir));
/* /*
clone the target repo. clone the target repo.
If you have issues, see: https://stackoverflow.com/questions/74082874 If you have issues, see: https://stackoverflow.com/questions/74082874
*/ */
options dlcreatedir; options dlcreatedir;
%let dirOut = %sysfunc(pathname(work))/package; %let dirOut = %sysfunc(pathname(work))/package;
libname _ "&dirOut."; libname _ "&dirOut.";
%put tgt clone rc=%sysfunc(GITFN_CLONE( %put tgt clone rc=%sysfunc(GITFN_CLONE(
git@github.com:SASPAC/sasjscore.git, git@github.com:SASPAC/sasjscore.git,
&dirOut, &dirOut,
git, git,
%str( ), %str( ),
/home/sasjssrv/.ssh/id_ecdsa.pub, /home/sasjssrv/.ssh/id_ecdsa.pub,
/home/sasjssrv/.ssh/id_ecdsa /home/sasjssrv/.ssh/id_ecdsa
)); ));
/* /*
Prepare Package Metadata Prepare Package Metadata
*/ */
data _null_; data _null_;
infile CARDS4; infile CARDS4;
file "&dirOut./description.sas"; file "&dirOut./description.sas";
input; input;
if _infile_ =: 'Version:' then put "Version: &version."; if _infile_ =: 'Version:' then put "Version: &version.";
else put _infile_; else put _infile_;
CARDS4; CARDS4;
Type: Package Type: Package
Package: SASjsCore Package: SASjsCore
Title: SAS Macros for Application Development Title: SAS Macros for Application Development
Version: $(PLACEHOLDER) Version: $(PLACEHOLDER)
Author: Allan Bowe Author: Allan Bowe
Maintainer: 4GL Ltd Maintainer: 4GL Ltd
License: MIT License: MIT
Encoding: UTF8 Encoding: UTF8
DESCRIPTION START: DESCRIPTION START:
The SASjs Macro Core library is a component of the SASjs framework, the The SASjs Macro Core library is a component of the SASjs framework, the
source for which is avaible here: https://github.com/sasjs source for which is avaible here: https://github.com/sasjs
Macros are divided by: Macros are divided by:
* Macro Functions (prefix mf_) * Macro Functions (prefix mf_)
* Macro Procedures (prefix mp_) * Macro Procedures (prefix mp_)
* Macros for Metadata (prefix mm_) * Macros for Metadata (prefix mm_)
* Macros for SASjs Server (prefix ms_) * Macros for SASjs Server (prefix ms_)
* Macros for Viya (prefix mv_) * Macros for Viya (prefix mv_)
DESCRIPTION END: DESCRIPTION END:
;;;; ;;;;
run; run;
/* /*
Prepare Package License Prepare Package License
*/ */
data _null_; data _null_;
file "&dirOut./license.sas"; file "&dirOut./license.sas";
infile "&dir/LICENSE"; infile "&dir/LICENSE";
input; input;
put _infile_; put _infile_;
run; run;
/* /*
Extract Core files into MacroCore Package location Extract Core files into MacroCore Package location
*/ */
data members(compress=char); data members(compress=char);
length dref dref2 $ 8 name name2 $ 32 path $ 2048; length dref dref2 $ 8 name name2 $ 32 path $ 2048;
rc = filename(dref, "&dir."); rc = filename(dref, "&dir.");
put dref=; put dref=;
did = dopen(dref); did = dopen(dref);
if did then if did then
do i = 1 to dnum(did); do i = 1 to dnum(did);
name = dread(did, i); name = dread(did, i);
if name in if name in
("base" "ddl" "fcmp" "lua" "meta" "metax" "server" "viya" "xplatform") ("base" "ddl" "fcmp" "lua" "meta" "metax" "server" "viya" "xplatform")
then do; then do;
rc = filename(dref2,catx("/", "&dir.", name)); rc = filename(dref2,catx("/", "&dir.", name));
put dref2= name; put dref2= name;
did2 = dopen(dref2); did2 = dopen(dref2);
if did2 then if did2 then
do j = 1 to dnum(did2); do j = 1 to dnum(did2);
name2 = dread(did2, j); name2 = dread(did2, j);
path = catx("/", "&dir.", name, name2); path = catx("/", "&dir.", name, name2);
if "sas" = scan(name2, -1, ".") then output; if "sas" = scan(name2, -1, ".") then output;
end; end;
rc = dclose(did2); rc = dclose(did2);
rc = filename(dref2); rc = filename(dref2);
end; end;
end; end;
rc = dclose(did); rc = dclose(did);
rc = filename(dref); rc = filename(dref);
keep name name2 path; keep name name2 path;
run; run;
%let temp_options = %sysfunc(getoption(source)) %sysfunc(getoption(notes)); %let temp_options = %sysfunc(getoption(source)) %sysfunc(getoption(notes));
options nosource nonotes; options nosource nonotes;
data _null_; data _null_;
set members; set members;
by name notsorted; by name notsorted;
ord + first.name; ord + first.name;
if first.name then if first.name then
do; do;
call execute('libname _ ' call execute('libname _ '
!! quote(catx("/", "&dirOut.", put(ord, z3.)!!"_macros")) !! quote(catx("/", "&dirOut.", put(ord, z3.)!!"_macros"))
!! ";" !! ";"
); );
put @1 "./" ord z3. "_macros/"; put @1 "./" ord z3. "_macros/";
end; end;
put @10 name2; put @10 name2;
call execute(" call execute("
data _null_; data _null_;
infile " !! quote(strip(path)) !! "; infile " !! quote(strip(path)) !! ";
file " !! quote(catx("/", "&dirOut.", put(ord, z3.)!!"_macros", name2)) !!"; file " !! quote(catx("/", "&dirOut.", put(ord, z3.)!!"_macros", name2)) !!";
input; input;
select; select;
when (2 = trigger) put _infile_; when (2 = trigger) put _infile_;
when (_infile_ = '/**') do; put '/*** HELP START ***//**'; trigger+1; end; when (_infile_ = '/**') do; put '/*** HELP START ***//**'; trigger+1; end;
when (_infile_ = '**/') do; put '**//*** HELP END ***/'; trigger+1; end; when (_infile_ = '**/') do; put '**//*** HELP END ***/'; trigger+1; end;
otherwise put _infile_; otherwise put _infile_;
end; end;
run;"); run;");
run; run;
options &temp_options.; options &temp_options.;
/* /*
Generate SASjsCore Package Generate SASjsCore Package
*/ */
%GeneratePackage( %GeneratePackage(
filesLocation=&dirOut filesLocation=&dirOut
) )
/** /**
* apply new version in a github action * apply new version in a github action
* 1. create folder * 1. create folder
* 2. create template yaml * 2. create template yaml
* 3. replace version number * 3. replace version number
*/ */
%mf_mkdir(&dirout/.github/workflows) %mf_mkdir(&dirout/.github/workflows)
%let desc=Version &version of sasjs/core is now on SAS PACKAGES :ok_hand:; %let desc=Version &version of sasjs/core is now on SAS PACKAGES :ok_hand:;
data _null_; data _null_;
file "&dirout/.github/workflows/release.yml"; file "&dirout/.github/workflows/release.yml";
put "name: SASjs Core Package Publish Tag"; put "name: SASjs Core Package Publish Tag";
put "on:"; put "on:";
put " push:"; put " push:";
put " branches:"; put " branches:";
put " - main"; put " - main";
put "jobs:"; put "jobs:";
put " update:"; put " update:";
put " runs-on: ubuntu-latest"; put " runs-on: ubuntu-latest";
put " steps:"; put " steps:";
put " - uses: actions/checkout@master"; put " - uses: actions/checkout@master";
put " - name: Make Release"; put " - name: Make Release";
put " uses: alice-biometrics/release-creator/@v1.0.5"; put " uses: alice-biometrics/release-creator/@v1.0.5";
put " with:"; put " with:";
put " github_token: ${{ secrets.GH_TOKEN }}"; put " github_token: ${{ secrets.GH_TOKEN }}";
put " branch: main"; put " branch: main";
put " draft: false"; put " draft: false";
put " version: &version"; put " version: &version";
put " description: '&desc'"; put " description: '&desc'";
run; run;
/** /**
* Add, Commit & Push! * Add, Commit & Push!
*/ */
%mp_gitstatus(&dirout,outds=work.gitstatus,mdebug=1) %mp_gitstatus(&dirout,outds=work.gitstatus,mdebug=1)
%mp_gitadd(&dirout,inds=work.gitstatus,mdebug=1) %mp_gitadd(&dirout,inds=work.gitstatus,mdebug=1)
data _null_; data _null_;
rc=gitfn_commit("&dirout" rc=gitfn_commit("&dirout"
,"HEAD","&sysuserid","sasjs@core" ,"HEAD","&sysuserid","sasjs@core"
,"FEAT: Releasing &version" ,"FEAT: Releasing &version"
); );
put rc=; put rc=;
rc=git_push( rc=git_push(
"&dirout" "&dirout"
,"git" ,"git"
,"" ,""
,"/home/sasjssrv/.ssh/id_ecdsa.pub" ,"/home/sasjssrv/.ssh/id_ecdsa.pub"
,"/home/sasjssrv/.ssh/id_ecdsa" ,"/home/sasjssrv/.ssh/id_ecdsa"
); );
run; run;

View File

@@ -539,7 +539,7 @@ data _null_;
put ' put " ""&wt"" : {"; '; put ' put " ""&wt"" : {"; ';
put ' put ''"nlobs":'' nlobs; '; put ' put ''"nlobs":'' nlobs; ';
put ' put '',"nvars":'' nvars; '; put ' put '',"nvars":'' nvars; ';
put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10 '; put ' %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y ';
put ' ,maxobs=&workobs '; put ' ,maxobs=&workobs ';
put ' ) '; put ' ) ';
put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; '; put ' data _null_; file &fref mod encoding=''utf-8'' termstr=lf; ';

View File

@@ -22,7 +22,7 @@
@param [in] uid= (0) Provide the userid on which to filter @param [in] uid= (0) Provide the userid on which to filter
@param [out] outds= (work.ms_getgroups) This output dataset will contain the @param [out] outds= (work.ms_getgroups) This output dataset will contain the
list of groups. Format: list of groups. Format:
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.| |NAME:$32.|DESCRIPTION:$256.|GROUPID:best.|
|---|---|---| |---|---|---|
|`SomeGroup `|`A group `|`1`| |`SomeGroup `|`A group `|`1`|
|`Another Group`|`this is a different group`|`2`| |`Another Group`|`this is a different group`|`2`|
@@ -58,7 +58,7 @@
%if %sysget(MODE)=desktop %then %do; %if %sysget(MODE)=desktop %then %do;
/* groups api does not exist in desktop mode */ /* groups api does not exist in desktop mode */
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $256. GROUPID 8;
name="&sysuserid"; name="&sysuserid";
description="&sysuserid (group - desktop mode)"; description="&sysuserid (group - desktop mode)";
groupid=1; groupid=1;
@@ -114,7 +114,7 @@ libname &libref JSON fileref=&fref1;
%if "&user"="0" and "&uid"="0" %then %do; %if "&user"="0" and "&uid"="0" %then %do;
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $256. GROUPID 8;
if _n_=1 then call missing(of _all_); if _n_=1 then call missing(of _all_);
set &libref..root; set &libref..root;
drop ordinal_root; drop ordinal_root;
@@ -122,7 +122,7 @@ libname &libref JSON fileref=&fref1;
%end; %end;
%else %do; %else %do;
data &outds; data &outds;
length NAME $32 DESCRIPTION $64. GROUPID 8; length NAME $32 DESCRIPTION $256. GROUPID 8;
if _n_=1 then call missing(of _all_); if _n_=1 then call missing(of _all_);
set &libref..groups; set &libref..groups;
drop ordinal_:; drop ordinal_:;

View File

@@ -39,8 +39,9 @@
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mf_getuniquefileref.sas @li mf_getuniquefileref.sas
@li mf_getuniquelibref.sas @li mf_getuniquename.sas
@li mp_abort.sas @li mp_abort.sas
@li mp_chop.sas
**/ **/
@@ -153,7 +154,10 @@ run;
run; run;
%end; %end;
filename &outref temp lrecl=32767; %local resp_path;
%let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
filename &outref "&resp_path" lrecl=32767;
/* prepare request*/ /* prepare request*/
proc http method='POST' headerin=&authref in=&mainref out=&outref proc http method='POST' headerin=&authref in=&mainref out=&outref
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131"; url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
@@ -161,6 +165,7 @@ proc http method='POST' headerin=&authref in=&mainref out=&outref
debug level=2; debug level=2;
%end; %end;
run; run;
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201) %if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
or &mdebug=1 or &mdebug=1
%then %do; %then %do;
@@ -176,11 +181,22 @@ or &mdebug=1
options &optval; options &optval;
%if &outlogds ne _null_ or &mdebug=1 %then %do; %if &outlogds ne _null_ or &mdebug=1 %then %do;
%local dumplib; %local matchstr chopout;
%let dumplib=%mf_getuniquelibref(); %let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
libname &dumplib json fileref=&outref; %let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
%mp_chop("&resp_path"
,matchvar=matchstr
,keep=LAST
,matchpoint=END
,outfile="&chopout"
,mdebug=&mdebug
)
data &outlogds; data &outlogds;
set &dumplib..log; infile "&chopout" lrecl=2000;
length line $2000;
line=_infile_;
%if &mdebug=1 %then %do; %if &mdebug=1 %then %do;
putlog line=; putlog line=;
%end; %end;

View File

@@ -108,47 +108,34 @@ run;
) )
/* SASjs services have the _webout embedded in wrapper JSON */ /* chop out JSON section */
/* Files can also be very large - so use a dedicated macro to chop it out */ %local matchstr chopout;
%local matchstr1 matchstr2 ; %let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
%let matchstr1={"status":"success","_webout":{; %let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
%let matchstr2=},"log":[{;
%let chopout1=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop1);
%let chopout2=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop2);
%mp_chop("%sysfunc(pathname(&fref1,F))" %mp_chop("%sysfunc(pathname(&fref1,F))"
,matchvar=matchstr1 ,matchvar=matchstr
,keep=LAST
,matchpoint=END
,offset=-1
,outfile="&chopout1"
,mdebug=&mdebug
)
%mp_chop("&chopout1"
,matchvar=matchstr2
,keep=FIRST ,keep=FIRST
,matchpoint=START ,matchpoint=START
,offset=1 ,offset=-1
,outfile="&chopout2" ,outfile="&chopout"
,mdebug=&mdebug ,mdebug=&mdebug
) )
%if &outlib ne 0 %then %do; %if &outlib ne 0 %then %do;
libname &outlib json "&chopout2"; libname &outlib json "&chopout";
%end; %end;
%if &outref ne 0 %then %do; %if &outref ne 0 %then %do;
filename &outref "&chopout2"; filename &outref "&chopout";
%end; %end;
%if &mdebug=0 %then %do; %if &mdebug=0 %then %do;
filename &webref clear; filename &webref clear;
filename &fref1 clear; filename &fref1 clear;
filename &fref2 clear;
%end; %end;
%else %do; %else %do;
%put &sysmacroname exit vars:; %put &sysmacroname exit vars:;
%put _local_; %put _local_;
%end; %end;
%mend ms_testservice; %mend ms_testservice;

View File

@@ -141,7 +141,7 @@
put " ""&wt"" : {"; put " ""&wt"" : {";
put '"nlobs":' nlobs; put '"nlobs":' nlobs;
put ',"nvars":' nvars; put ',"nvars":' nvars;
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y,maxobs=10 %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,showmeta=Y
,maxobs=&workobs ,maxobs=&workobs
) )
data _null_; file &fref mod encoding='utf-8' termstr=lf; data _null_; file &fref mod encoding='utf-8' termstr=lf;

View File

@@ -4,7 +4,7 @@
@brief Testing mv_jobflow macro @brief Testing mv_jobflow macro
@details One of the remote jobs aborts with syscc>0 - test to @details One of the remote jobs aborts with syscc>0 - test to
make sure this comes back to the calling session make sure this comes back to the calling session
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mp_assert.sas @li mp_assert.sas
@li mv_createjob.sas @li mv_createjob.sas

View File

@@ -3,7 +3,7 @@
@brief Testing mv_jobflow macro @brief Testing mv_jobflow macro
@details All jobs complete successfully with syscc = 0 - test to @details All jobs complete successfully with syscc = 0 - test to
make sure this comes back to the calling session make sure this comes back to the calling session
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mp_assert.sas @li mp_assert.sas
@li mv_createjob.sas @li mv_createjob.sas

View File

@@ -4,7 +4,7 @@
@brief Testing mv_registerclient.sas macro @brief Testing mv_registerclient.sas macro
@details Tests for successful registration. For this to work, the test @details Tests for successful registration. For this to work, the test
account must be an admin. account must be an admin.
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mf_getuniquename.sas @li mf_getuniquename.sas
@li mp_assertcolvals.sas @li mp_assertcolvals.sas

View File

@@ -1,10 +1,9 @@
/** /**
@file @file
@brief Testing mv_registerclient.sas macro @brief Testing mv_registerclient.sas macro
@details Tests for unsuccessful registration. To do this, overrides are @details Tests for unsuccessful registration. To do this, overrides are
applied for the mf_loc.sas and mp_abort.sas macros. applied for the mf_loc.sas and mp_abort.sas macros.
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mp_assert.sas @li mp_assert.sas
@li mv_registerclient.sas @li mv_registerclient.sas

View File

@@ -1,60 +1,60 @@
/** /**
@file mfv_existsashdat.sas @file mfv_existsashdat.sas
@brief Checks whether a CAS sashdat dataset exists in persistent storage. @brief Checks whether a CAS sashdat dataset exists in persistent storage.
@details Can be used in open code, eg as follows: @details Can be used in open code, eg as follows:
%if %mfv_existsashdat(libds=casuser.sometable) %then %put yes it does!; %if %mfv_existsashdat(libds=casuser.sometable) %then %put yes it does!;
The function uses `dosubl()` to run the `table.fileinfo` action, for the The function uses `dosubl()` to run the `table.fileinfo` action, for the
specified library, filtering for `*.sashdat` tables. The results are stored specified library, filtering for `*.sashdat` tables. The results are stored
in a WORK table (&outprefix._&lib). If that table already exists, it is in a WORK table (&outprefix._&lib). If that table already exists, it is
queried instead, to avoid the dosubl() performance hit. queried instead, to avoid the dosubl() performance hit.
To force a rescan, just use a new `&outprefix` value, or delete the table(s) To force a rescan, just use a new `&outprefix` value, or delete the table(s)
before running the function. before running the function.
@param libds library.dataset @param libds library.dataset
@param outprefix= (work.mfv_existsashdat) Used to store the current HDATA @param outprefix= (work.mfv_existsashdat) Used to store the current HDATA
tables to improve subsequent query performance. This reference is a prefix tables to improve subsequent query performance. This reference is a prefix
and is converted to `&prefix._{libref}` and is converted to `&prefix._{libref}`
@return output returns 1 or 0 @return output returns 1 or 0
@version 0.2 @version 0.2
@author Mathieu Blauw @author Mathieu Blauw
**/ **/
%macro mfv_existsashdat(libds,outprefix=work.mfv_existsashdat %macro mfv_existsashdat(libds,outprefix=work.mfv_existsashdat
); );
%local rc dsid name lib ds; %local rc dsid name lib ds;
%let lib=%upcase(%scan(&libds,1,'.')); %let lib=%upcase(%scan(&libds,1,'.'));
%let ds=%upcase(%scan(&libds,-1,'.')); %let ds=%upcase(%scan(&libds,-1,'.'));
/* if table does not exist, create it */ /* if table does not exist, create it */
%if %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do; %if %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do;
%let rc=%sysfunc(dosubl(%nrstr( %let rc=%sysfunc(dosubl(%nrstr(
/* Read in table list (once per &lib per session) */ /* Read in table list (once per &lib per session) */
proc cas; proc cas;
table.fileinfo result=source_list /caslib="&lib"; table.fileinfo result=source_list /caslib="&lib";
val=findtable(source_list); val=findtable(source_list);
saveresult val dataout=&outprefix._&lib; saveresult val dataout=&outprefix._&lib;
quit; quit;
/* Only keep name, without file extension */ /* Only keep name, without file extension */
data &outprefix._&lib; data &outprefix._&lib;
set &outprefix._&lib(where=(Name like '%.sashdat') keep=Name); set &outprefix._&lib(where=(Name like '%.sashdat') keep=Name);
Name=upcase(scan(Name,1,'.')); Name=upcase(scan(Name,1,'.'));
run; run;
))); )));
%end; %end;
/* Scan table for hdat existence */ /* Scan table for hdat existence */
%let dsid=%sysfunc(open(&outprefix._&lib(where=(name="&ds")))); %let dsid=%sysfunc(open(&outprefix._&lib(where=(name="&ds"))));
%syscall set(dsid); %syscall set(dsid);
%let rc = %sysfunc(fetch(&dsid)); %let rc = %sysfunc(fetch(&dsid));
%let rc = %sysfunc(close(&dsid)); %let rc = %sysfunc(close(&dsid));
/* Return result */ /* Return result */
%if "%trim(&name)"="%trim(&ds)" %then 1; %if "%trim(&name)"="%trim(&ds)" %then 1;
%else 0; %else 0;
%mend mfv_existsashdat; %mend mfv_existsashdat;