mirror of
https://github.com/sasjs/core.git
synced 2026-01-07 01:20:05 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb2ccfbbca | ||
|
|
70e508e583 | ||
|
|
8b0acf2eae | ||
|
|
d254870439 | ||
|
|
303225cb85 | ||
|
|
90de167643 | ||
|
|
8ee997de8e | ||
|
|
e27f6ac716 | ||
|
|
ec4de95fcf | ||
|
|
df0fa95519 | ||
|
|
2fe7fba79b | ||
|
|
e40234ee29 | ||
|
|
a287cc27a7 | ||
|
|
921186eb74 | ||
|
|
6fd215ceff | ||
|
|
0297509aa0 | ||
|
|
c5a8bc745d | ||
|
|
36aa466561 | ||
|
|
009485e5b9 | ||
|
|
eb01c8772d | ||
|
|
e3fb69928c | ||
|
|
65afa14466 | ||
|
|
0176b19616 | ||
|
|
9f3dfd9a59 | ||
|
|
513ea354ab | ||
|
|
7b686e11c9 | ||
|
|
3997000266 |
9
.github/dependabot.yml
vendored
Normal file
9
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: monthly
|
||||||
|
open-pull-requests-limit: 3
|
||||||
|
allow:
|
||||||
|
- dependency-type: "production"
|
||||||
14
README.md
14
README.md
@@ -81,7 +81,7 @@ Macros used for interfacing with SAS Viya.
|
|||||||
|
|
||||||
Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
|
Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
|
||||||
|
|
||||||
To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert your LUA into a data step with put statements, and create the macro wrapper with a `ml_` prefix. You can then use your module in any program by running:
|
To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert all files with a ".lua" extension into a macro wrapper with an `ml_` prefix (embedding the necessary data step put statements). You can then use your module in any program by running:
|
||||||
|
|
||||||
```sas
|
```sas
|
||||||
/* compile the lua module */
|
/* compile the lua module */
|
||||||
@@ -95,8 +95,7 @@ endsubmit;
|
|||||||
run;
|
run;
|
||||||
```
|
```
|
||||||
|
|
||||||
- X command enabled
|
- Prefixes: _ml_
|
||||||
- Prefixes: _mmw_,_mmu_,_mmx_
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -129,11 +128,11 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
|||||||
- _mf_ for macro functions (can be used in open code).
|
- _mf_ for macro functions (can be used in open code).
|
||||||
- _ml_ for macros that are used to compile LUA modules
|
- _ml_ for macros that are used to compile LUA modules
|
||||||
- _mm_ for metadata macros (interface with the metadata server).
|
- _mm_ for metadata macros (interface with the metadata server).
|
||||||
- _mmx_ for macros that use metadata and are XCMD enabled
|
- _mmx_ for macros that use metadata and are XCMD enabled (working on both windows and unix)
|
||||||
- _mp_ for macro procedures (which generate sas code)
|
- _mp_ for macro procedures (which generate sas code)
|
||||||
- _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
- _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
|
||||||
- _mv_ for macro procedures that will only work in Viya
|
- _mv_ for macro procedures that will only work in Viya
|
||||||
- _mx_ for macros that are XCMD enabled
|
- _mx_ for macros that are XCMD enabled (working on both windows and unix)
|
||||||
- follow verb-noun convention
|
- follow verb-noun convention
|
||||||
- unix style line endings (lf)
|
- unix style line endings (lf)
|
||||||
- individual lines should be no more than 80 characters long
|
- individual lines should be no more than 80 characters long
|
||||||
@@ -193,11 +192,12 @@ When contributing to this library, it is therefore important to ensure that all
|
|||||||
|
|
||||||
## Breaking Changes
|
## Breaking Changes
|
||||||
|
|
||||||
We are currently on major release v4. Breaking changes should be marked with the [deprecated](https://www.doxygen.nl/manual/commands.html#cmddeprecated) doxygen tag. The following changes are planned when the next major (breaking) release becomes necessary:
|
We are currently on major release v4. Breaking changes should be marked with the [deprecated](https://www.doxygen.nl/manual/commands.html#cmddeprecated) doxygen tag. The following changes are planned when the next major/breaking release (v5) becomes necessary:
|
||||||
|
|
||||||
* mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
|
* mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
|
||||||
* `insert_cmplib` option of mcf_xxx macros will be deprecated (the option is now checked automatically with value inserted only if needed)
|
* `insert_cmplib` option of mcf_xxx macros will be deprecated (the option is now checked automatically with value inserted only if needed)
|
||||||
* mcf_xxx macros to have `wrap=` option defaulted to YES for convenience
|
* mcf_xxx macros to have `wrap=` option defaulted to YES for convenience. Set this option explicitly to avoid issues.
|
||||||
|
* mp_getddl.sas to be renamed to mp_ds2ddl.sas (consistent with other ds2xxx macros). A wrapper macro is already in place, and you are able to use this immediately. The default for SHOWLOG will also be YES instead of NO.
|
||||||
|
|
||||||
## Star Gazing
|
## Star Gazing
|
||||||
|
|
||||||
|
|||||||
269
all.sas
269
all.sas
@@ -352,6 +352,7 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
|
|||||||
@li /data
|
@li /data
|
||||||
@li /jobs
|
@li /jobs
|
||||||
@li /services
|
@li /services
|
||||||
|
@li /tests
|
||||||
@li /tests/jobs
|
@li /tests/jobs
|
||||||
@li /tests/services
|
@li /tests/services
|
||||||
@li /tests/macros
|
@li /tests/macros
|
||||||
@@ -383,9 +384,13 @@ https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md#functionex
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* First check we are not in the tests/macros folder (which has no subfolders)
|
* First check we are not in the tests/macros folder (which has no subfolders)
|
||||||
|
* or specifically in the testsetup or testteardown services
|
||||||
*/
|
*/
|
||||||
%if %index(&pgm,/tests/macros/) %then %do;
|
%if %index(&pgm,/tests/macros/)
|
||||||
%let root=%substr(&pgm,1,%index(&pgm,/tests/macros)-1);
|
or %index(&pgm,/tests/testsetup)
|
||||||
|
or %index(&pgm,/tests/testteardown)
|
||||||
|
%then %do;
|
||||||
|
%let root=%substr(&pgm,1,%index(&pgm,/tests)-1);
|
||||||
&root
|
&root
|
||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
@@ -1802,7 +1807,7 @@ Usage:
|
|||||||
|
|
||||||
%mend mf_uid;/**
|
%mend mf_uid;/**
|
||||||
@file
|
@file
|
||||||
@brief Checks if a set of macro variables exist / contain values.
|
@brief Checks if a set of macro variables exist AND contain values.
|
||||||
@details Writes ERROR to log if abortType is SOFT, else will call %mf_abort.
|
@details Writes ERROR to log if abortType is SOFT, else will call %mf_abort.
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -1816,10 +1821,11 @@ Usage:
|
|||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_abort.sas
|
@li mf_abort.sas
|
||||||
|
|
||||||
@param verifyvars space separated list of macro variable names
|
@param [in] verifyvars Space separated list of macro variable names
|
||||||
@param makeupcase= set to YES to convert all variable VALUES to
|
@param [in] makeupcase= (NO) Set to YES to convert all variable VALUES to
|
||||||
uppercase.
|
uppercase.
|
||||||
@param mAbort= Abort Type. Default is SOFT (writes err to log).
|
@param [in] mAbort= (SOFT) Abort Type. When SOFT, simply writes an err
|
||||||
|
message to the log.
|
||||||
Set to any other value to call mf_abort (which can be configured to abort in
|
Set to any other value to call mf_abort (which can be configured to abort in
|
||||||
various fashions according to context).
|
various fashions according to context).
|
||||||
|
|
||||||
@@ -1860,9 +1866,15 @@ Usage:
|
|||||||
|
|
||||||
%goto exit_success;
|
%goto exit_success;
|
||||||
%exit_err:
|
%exit_err:
|
||||||
%if &mAbort=SOFT %then %put %str(ERR)OR: &abortmsg;
|
%put %str(ERR)OR: &abortmsg;
|
||||||
%else %mf_abort(mac=mf_verifymacvars,type=&mabort,msg=&abortmsg);
|
%mf_abort(iftrue=(&mabort ne SOFT),
|
||||||
|
mac=mf_verifymacvars,
|
||||||
|
msg=%str(&abortmsg)
|
||||||
|
)
|
||||||
|
0
|
||||||
|
%return;
|
||||||
%exit_success:
|
%exit_success:
|
||||||
|
1
|
||||||
|
|
||||||
%mend mf_verifymacvars;
|
%mend mf_verifymacvars;
|
||||||
/**
|
/**
|
||||||
@@ -3521,6 +3533,12 @@ run;
|
|||||||
make use of permanent tables. To avoid duplication in definitions, this
|
make use of permanent tables. To avoid duplication in definitions, this
|
||||||
macro provides a central location for managing the corresponding DDL.
|
macro provides a central location for managing the corresponding DDL.
|
||||||
|
|
||||||
|
Note - this macro is likely to be deprecated in future in favour of a
|
||||||
|
dedicated "datamodel" folder (prefix mddl)
|
||||||
|
|
||||||
|
Any corresponding data would go in a seperate repo, to avoid this one
|
||||||
|
ballooning in size!
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
|
|
||||||
%mp_coretable(LOCKTABLE,libds=work.locktable)
|
%mp_coretable(LOCKTABLE,libds=work.locktable)
|
||||||
@@ -4715,7 +4733,7 @@ quit;
|
|||||||
numbers).
|
numbers).
|
||||||
@param [out] outfile= The output filename - should be quoted.
|
@param [out] outfile= The output filename - should be quoted.
|
||||||
@param [out] outref= (0) The output fileref (takes precedence if provided)
|
@param [out] outref= (0) The output fileref (takes precedence if provided)
|
||||||
@param [in] outencoding= (0) The output encoding to use (unquoted)
|
@param [in] outencoding= (0) The (quoted) output encoding to use, eg `"UTF-8"`
|
||||||
@param [in] termstr= (CRLF) The line seperator to use. For SASJS, will
|
@param [in] termstr= (CRLF) The line seperator to use. For SASJS, will
|
||||||
always be CRLF. Valid values:
|
always be CRLF. Valid values:
|
||||||
@li CRLF
|
@li CRLF
|
||||||
@@ -4751,7 +4769,7 @@ quit;
|
|||||||
%if %index(&ds,.)=0 %then %let ds=WORK.&ds;
|
%if %index(&ds,.)=0 %then %let ds=WORK.&ds;
|
||||||
|
|
||||||
%if &outencoding=0 %then %let outencoding=;
|
%if &outencoding=0 %then %let outencoding=;
|
||||||
%else %let outencoding=encoding="&outencoding";
|
%else %let outencoding=encoding=&outencoding;
|
||||||
|
|
||||||
%if &outref=0 %then %let outloc=&outfile;
|
%if &outref=0 %then %let outloc=&outfile;
|
||||||
%else %let outloc=&outref;
|
%else %let outloc=&outref;
|
||||||
@@ -4876,6 +4894,35 @@ data _null_;
|
|||||||
run;
|
run;
|
||||||
|
|
||||||
%mend mp_ds2csv;/**
|
%mend mp_ds2csv;/**
|
||||||
|
@file
|
||||||
|
@brief A wrapper for mp_getddl.sas
|
||||||
|
@details In the next release, this will be the main version.
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_getddl.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_ds2ddl(libds,fref=getddl,flavour=SAS,showlog=YES,schema=
|
||||||
|
,applydttm=NO
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
|
%local libref;
|
||||||
|
%let libds=%upcase(&libds);
|
||||||
|
%let libref=%scan(&libds,1,.);
|
||||||
|
%if &libref=&libds %then %let libds=WORK.&libds;
|
||||||
|
|
||||||
|
%mp_getddl(%scan(&libds,1,.)
|
||||||
|
,%scan(&libds,2,.)
|
||||||
|
,fref=&fref
|
||||||
|
,flavour=SAS
|
||||||
|
,showlog=&showlog
|
||||||
|
,schema=&schema
|
||||||
|
,applydttm=&applydttm
|
||||||
|
)
|
||||||
|
|
||||||
|
%mend mp_ds2ddl;/**
|
||||||
@file
|
@file
|
||||||
@brief Converts every value in a dataset to formatted value
|
@brief Converts every value in a dataset to formatted value
|
||||||
@details Converts every value to it's formatted value. All variables will
|
@details Converts every value to it's formatted value. All variables will
|
||||||
@@ -5382,7 +5429,8 @@ options varlenchk=&optval;
|
|||||||
SYSCC to 1008 if bad records are found, and call mp_abort.sas for a
|
SYSCC to 1008 if bad records are found, and call mp_abort.sas for a
|
||||||
graceful service exit (configurable).
|
graceful service exit (configurable).
|
||||||
|
|
||||||
Used for dynamic filtering in [Data Controller for SAS®](https://datacontroller.io).
|
Used for dynamic filtering in [Data Controller for SAS®](
|
||||||
|
https://datacontroller.io).
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -5501,7 +5549,7 @@ data &outds;
|
|||||||
output;
|
output;
|
||||||
end;
|
end;
|
||||||
if OPERATOR_NM not in
|
if OPERATOR_NM not in
|
||||||
('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS')
|
('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS','GE','LE')
|
||||||
then do;
|
then do;
|
||||||
REASON_CD='Invalid OPERATOR_NM: '!!cats(OPERATOR_NM);
|
REASON_CD='Invalid OPERATOR_NM: '!!cats(OPERATOR_NM);
|
||||||
putlog REASON_CD= OPERATOR_NM=;
|
putlog REASON_CD= OPERATOR_NM=;
|
||||||
@@ -5689,8 +5737,13 @@ filename &outref temp;
|
|||||||
https://sasapps.io)). This macro is also used in [Data Controller for SAS](
|
https://sasapps.io)). This macro is also used in [Data Controller for SAS](
|
||||||
https://datacontroller.io).
|
https://datacontroller.io).
|
||||||
|
|
||||||
|
A more recent feature of this macro is the ability to support filter queries
|
||||||
|
on Format Catalogs. This is achieved by adding a `-FC` suffix to the `libds`
|
||||||
|
parameter - where the "ds" in this case is the catalog name.
|
||||||
|
|
||||||
@param [in] libds= The target dataset to be filtered (lib should be assigned)
|
|
||||||
|
@param [in] libds= The target dataset to be filtered (lib should be assigned).
|
||||||
|
If filtering a format catalog, add the following suffix: `-FC`.
|
||||||
@param [in] queryds= (WORK.FILTERQUERY) The temporary input query dataset to
|
@param [in] queryds= (WORK.FILTERQUERY) The temporary input query dataset to
|
||||||
be validated. Has the following format:
|
be validated. Has the following format:
|
||||||
|GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
|
|GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
|
||||||
@@ -5759,7 +5812,10 @@ filename &outref temp;
|
|||||||
%put &sysmacroname entry vars:;
|
%put &sysmacroname entry vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
|
|
||||||
%local ds1 ds2 ds3 ds4 filter_hash;
|
%local ds0 ds1 ds2 ds3 ds4 filter_hash orig_libds;
|
||||||
|
%let libds=%upcase(&libds);
|
||||||
|
%let orig_libds=&libds;
|
||||||
|
|
||||||
%mp_abort(iftrue= (&syscc ne 0)
|
%mp_abort(iftrue= (&syscc ne 0)
|
||||||
,mac=mp_filterstore
|
,mac=mp_filterstore
|
||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
@@ -5777,12 +5833,49 @@ filename &outref temp;
|
|||||||
,msg=%str(Invalid lock_table value: &lock_table)
|
,msg=%str(Invalid lock_table value: &lock_table)
|
||||||
)
|
)
|
||||||
|
|
||||||
/* validate query */
|
/**
|
||||||
|
* validate query
|
||||||
|
* use format catalog export, if a format
|
||||||
|
*/
|
||||||
|
%if "%substr(&libds,%length(&libds)-2,3)"="-FC" %then %do;
|
||||||
|
%let libds=%scan(&libds,1,-); /* chop off -FC extension */
|
||||||
|
%let ds0=%mf_getuniquename(prefix=fmtds_);
|
||||||
|
/*
|
||||||
|
There is no need to export the entire format catalog here - the validations
|
||||||
|
are done against the data model, not the data values. So we can simply
|
||||||
|
hardcode the structure based on the cntlout dataset.
|
||||||
|
*/
|
||||||
|
proc sql;
|
||||||
|
create table &ds0(
|
||||||
|
FMTNAME char(32)
|
||||||
|
,START char(16)
|
||||||
|
,END char(16)
|
||||||
|
,LABEL char(256)
|
||||||
|
,MIN num length=3
|
||||||
|
,MAX num length=3
|
||||||
|
,DEFAULT num length=3
|
||||||
|
,LENGTH num length=3
|
||||||
|
,FUZZ num
|
||||||
|
,PREFIX char(2)
|
||||||
|
,MULT num
|
||||||
|
,FILL char(1)
|
||||||
|
,NOEDIT num length=3
|
||||||
|
,TYPE char(1)
|
||||||
|
,SEXCL char(1)
|
||||||
|
,EEXCL char(1)
|
||||||
|
,HLO char(13)
|
||||||
|
,DECSEP char(1)
|
||||||
|
,DIG3SEP char(1)
|
||||||
|
,DATATYPE char(8)
|
||||||
|
,LANGUAGE char(8)
|
||||||
|
);
|
||||||
|
%let libds=&ds0;
|
||||||
|
%end;
|
||||||
%mp_filtercheck(&queryds,targetds=&libds,abort=YES)
|
%mp_filtercheck(&queryds,targetds=&libds,abort=YES)
|
||||||
|
|
||||||
/* hash the result */
|
/* hash the result */
|
||||||
%let ds1=%mf_getuniquename(prefix=hashds);
|
%let ds1=%mf_getuniquename(prefix=hashds);
|
||||||
%mp_hashdataset(&queryds,outds=&ds1,salt=&libds)
|
%mp_hashdataset(&queryds,outds=&ds1,salt=&orig_libds)
|
||||||
%let filter_hash=%upcase(%mf_getvalue(&ds1,hashkey));
|
%let filter_hash=%upcase(%mf_getvalue(&ds1,hashkey));
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -5813,7 +5906,7 @@ run;
|
|||||||
%let ds3=%mf_getuniquename(prefix=filtersum);
|
%let ds3=%mf_getuniquename(prefix=filtersum);
|
||||||
data work.&ds3;
|
data work.&ds3;
|
||||||
if 0 then set &filter_summary;
|
if 0 then set &filter_summary;
|
||||||
filter_table=symget('libds');
|
filter_table="&orig_libds";
|
||||||
filter_hash="&filter_hash";
|
filter_hash="&filter_hash";
|
||||||
PROCESSED_DTTM=%sysfunc(datetime());
|
PROCESSED_DTTM=%sysfunc(datetime());
|
||||||
output;
|
output;
|
||||||
@@ -7043,6 +7136,10 @@ create table &outsummary as
|
|||||||
proc format library=&&fmtloc&i CNTLOUT=&tempds;
|
proc format library=&&fmtloc&i CNTLOUT=&tempds;
|
||||||
select &&fmtname&i;
|
select &&fmtname&i;
|
||||||
run;
|
run;
|
||||||
|
data &tempds;
|
||||||
|
length label $256;
|
||||||
|
set &tempds;
|
||||||
|
run;
|
||||||
proc append base=&outdetail data=&tempds;
|
proc append base=&outdetail data=&tempds;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
@@ -10800,17 +10897,19 @@ create table &outds as
|
|||||||
|
|
||||||
%mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
|
%mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
|
||||||
|
|
||||||
|
@param [in] contenttype= (TEXTS) Either TEXT, ZIP, CSV, EXCEL
|
||||||
|
@param [in] inloc= /path/to/file.ext to be sent
|
||||||
|
@param [in] inref= fileref of file to be sent (if provided, overrides `inloc`)
|
||||||
|
@param [in] iftrue= (1=1) Provide a condition under which to execute.
|
||||||
|
@param [out] outname= the name of the file, as downloaded by the browser
|
||||||
|
@param [out] outref= (_webout) The destination where the file should be
|
||||||
|
streamed.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mf_getplatform.sas
|
||||||
@li mp_binarycopy.sas
|
@li mp_binarycopy.sas
|
||||||
|
|
||||||
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
|
||||||
@param inloc= /path/to/file.ext to be sent
|
|
||||||
@param inref= fileref of file to be sent (if provided, overrides `inloc`)
|
|
||||||
@param outname= the name of the file, as downloaded by the browser
|
|
||||||
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@source https://github.com/sasjs/core
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -10818,12 +10917,16 @@ create table &outds as
|
|||||||
contenttype=TEXT
|
contenttype=TEXT
|
||||||
,inloc=
|
,inloc=
|
||||||
,inref=0
|
,inref=0
|
||||||
|
,iftrue=%str(1=1)
|
||||||
,outname=
|
,outname=
|
||||||
|
,outref=_webout
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%let contentype=%upcase(&contenttype);
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
%local platform; %let platform=%mf_getplatform();
|
|
||||||
|
|
||||||
|
%let contentype=%upcase(&contenttype);
|
||||||
|
%let outref=%upcase(&outref);
|
||||||
|
%local platform; %let platform=%mf_getplatform();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check engine type to avoid the below err message:
|
* check engine type to avoid the below err message:
|
||||||
@@ -10832,20 +10935,20 @@ create table &outds as
|
|||||||
%local streamweb;
|
%local streamweb;
|
||||||
%let streamweb=0;
|
%let streamweb=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set sashelp.vextfl(where=(upcase(fileref)="_WEBOUT"));
|
set sashelp.vextfl(where=(upcase(fileref)="&outref"));
|
||||||
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if &contentype=ZIP %then %do;
|
%if &contentype=CSV %then %do;
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
rc=stpsrv_header('Content-type','application/zip');
|
rc=stpsrv_header('Content-type','application/csv');
|
||||||
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
||||||
contenttype='application/zip'
|
contenttype='application/csv'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -10858,11 +10961,52 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype='application/vnd.ms-excel'
|
contenttype='application/vnd.ms-excel'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
%else %if &contentype=GIF or &contentype=JPEG or &contentype=PNG %then %do;
|
||||||
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
rc=stpsrv_header('Content-type',"image/%lowcase(&contenttype)");
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
||||||
|
contenttype="image/%lowcase(&contenttype)";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if &contentype=HTML %then %do;
|
||||||
|
%if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
||||||
|
contenttype="text/html";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if &contentype=TEXT %then %do;
|
||||||
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
rc=stpsrv_header('Content-type','application/text');
|
||||||
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
||||||
|
contenttype='application/text'
|
||||||
|
contentdisp="attachment; filename=&outname";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
|
||||||
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
rc=stpsrv_header('Content-type',"font/%lowcase(&contenttype)");
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
||||||
|
contenttype="font/%lowcase(&contenttype)";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
%else %if &contentype=XLSX %then %do;
|
%else %if &contentype=XLSX %then %do;
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -10872,54 +11016,34 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype=
|
contenttype=
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %if &contentype=TEXT %then %do;
|
%else %if &contentype=ZIP %then %do;
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
rc=stpsrv_header('Content-type','application/text');
|
rc=stpsrv_header('Content-type','application/zip');
|
||||||
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
||||||
contenttype='application/text'
|
contenttype='application/zip'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %if &contentype=CSV %then %do;
|
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
||||||
data _null_;
|
|
||||||
rc=stpsrv_header('Content-type','application/csv');
|
|
||||||
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
||||||
run;
|
|
||||||
%end;
|
|
||||||
%else %if &platform=SASVIYA %then %do;
|
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
||||||
contenttype='application/csv'
|
|
||||||
contentdisp="attachment; filename=&outname";
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %if &contentype=HTML %then %do;
|
|
||||||
%if &platform=SASVIYA %then %do;
|
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
|
||||||
contenttype="text/html";
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %do;
|
%else %do;
|
||||||
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
||||||
%return;
|
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%if &inref ne 0 %then %do;
|
%if &inref ne 0 %then %do;
|
||||||
%mp_binarycopy(inref=&inref,outref=_webout)
|
%mp_binarycopy(inref=&inref,outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%mp_binarycopy(inloc="&inloc",outref=_webout)
|
%mp_binarycopy(inloc="&inloc",outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mp_streamfile;
|
%mend mp_streamfile;
|
||||||
@@ -12576,7 +12700,10 @@ run;
|
|||||||
%&mD.put Executing &sysmacroname..sas;
|
%&mD.put Executing &sysmacroname..sas;
|
||||||
%&mD.put _local_;
|
%&mD.put _local_;
|
||||||
|
|
||||||
%mf_verifymacvars(tree name)
|
%mp_abort(iftrue= (%mf_verifymacvars(tree name)=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: tree name)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check tree exists
|
* check tree exists
|
||||||
@@ -12800,7 +12927,10 @@ run;
|
|||||||
%&mD.put Executing &sysmacroname..sas;
|
%&mD.put Executing &sysmacroname..sas;
|
||||||
%&mD.put _local_;
|
%&mD.put _local_;
|
||||||
|
|
||||||
%mf_verifymacvars(tree name)
|
%mp_abort(iftrue= (%mf_verifymacvars(tree name)=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: tree name)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check tree exists
|
* check tree exists
|
||||||
@@ -13169,12 +13299,14 @@ run;
|
|||||||
filename &frefin temp;
|
filename &frefin temp;
|
||||||
filename &frefout temp;
|
filename &frefout temp;
|
||||||
|
|
||||||
|
%mp_abort(iftrue= (
|
||||||
|
&engine=BASE & %mf_verifymacvars(libname libref engine servercontext tree)=0
|
||||||
|
)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: libname libref engine servercontext tree)
|
||||||
|
)
|
||||||
|
|
||||||
%if &engine=BASE %then %do;
|
%if &engine=BASE %then %do;
|
||||||
|
|
||||||
%mf_verifymacvars(libname libref engine servercontext tree)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the ServerContext exists
|
* Check that the ServerContext exists
|
||||||
*/
|
*/
|
||||||
@@ -13465,7 +13597,12 @@ filename &frefout temp;
|
|||||||
%&mD.put Executing mm_CreateSTP.sas;
|
%&mD.put Executing mm_CreateSTP.sas;
|
||||||
%&mD.put _local_;
|
%&mD.put _local_;
|
||||||
|
|
||||||
%mf_verifymacvars(stpname filename directory tree)
|
%mp_abort(
|
||||||
|
iftrue=(%mf_verifymacvars(stpname filename directory tree)=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: stpname filename directory tree)
|
||||||
|
)
|
||||||
|
|
||||||
%mp_dropmembers(%scan(&outds,2,.))
|
%mp_dropmembers(%scan(&outds,2,.))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
@li /data
|
@li /data
|
||||||
@li /jobs
|
@li /jobs
|
||||||
@li /services
|
@li /services
|
||||||
|
@li /tests
|
||||||
@li /tests/jobs
|
@li /tests/jobs
|
||||||
@li /tests/services
|
@li /tests/services
|
||||||
@li /tests/macros
|
@li /tests/macros
|
||||||
@@ -46,9 +47,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* First check we are not in the tests/macros folder (which has no subfolders)
|
* First check we are not in the tests/macros folder (which has no subfolders)
|
||||||
|
* or specifically in the testsetup or testteardown services
|
||||||
*/
|
*/
|
||||||
%if %index(&pgm,/tests/macros/) %then %do;
|
%if %index(&pgm,/tests/macros/)
|
||||||
%let root=%substr(&pgm,1,%index(&pgm,/tests/macros)-1);
|
or %index(&pgm,/tests/testsetup)
|
||||||
|
or %index(&pgm,/tests/testteardown)
|
||||||
|
%then %do;
|
||||||
|
%let root=%substr(&pgm,1,%index(&pgm,/tests)-1);
|
||||||
&root
|
&root
|
||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Checks if a set of macro variables exist / contain values.
|
@brief Checks if a set of macro variables exist AND contain values.
|
||||||
@details Writes ERROR to log if abortType is SOFT, else will call %mf_abort.
|
@details Writes ERROR to log if abortType is SOFT, else will call %mf_abort.
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -14,10 +14,11 @@
|
|||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_abort.sas
|
@li mf_abort.sas
|
||||||
|
|
||||||
@param verifyvars space separated list of macro variable names
|
@param [in] verifyvars Space separated list of macro variable names
|
||||||
@param makeupcase= set to YES to convert all variable VALUES to
|
@param [in] makeupcase= (NO) Set to YES to convert all variable VALUES to
|
||||||
uppercase.
|
uppercase.
|
||||||
@param mAbort= Abort Type. Default is SOFT (writes err to log).
|
@param [in] mAbort= (SOFT) Abort Type. When SOFT, simply writes an err
|
||||||
|
message to the log.
|
||||||
Set to any other value to call mf_abort (which can be configured to abort in
|
Set to any other value to call mf_abort (which can be configured to abort in
|
||||||
various fashions according to context).
|
various fashions according to context).
|
||||||
|
|
||||||
@@ -58,8 +59,14 @@
|
|||||||
|
|
||||||
%goto exit_success;
|
%goto exit_success;
|
||||||
%exit_err:
|
%exit_err:
|
||||||
%if &mAbort=SOFT %then %put %str(ERR)OR: &abortmsg;
|
%put %str(ERR)OR: &abortmsg;
|
||||||
%else %mf_abort(mac=mf_verifymacvars,type=&mabort,msg=&abortmsg);
|
%mf_abort(iftrue=(&mabort ne SOFT),
|
||||||
|
mac=mf_verifymacvars,
|
||||||
|
msg=%str(&abortmsg)
|
||||||
|
)
|
||||||
|
0
|
||||||
|
%return;
|
||||||
%exit_success:
|
%exit_success:
|
||||||
|
1
|
||||||
|
|
||||||
%mend mf_verifymacvars;
|
%mend mf_verifymacvars;
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
make use of permanent tables. To avoid duplication in definitions, this
|
make use of permanent tables. To avoid duplication in definitions, this
|
||||||
macro provides a central location for managing the corresponding DDL.
|
macro provides a central location for managing the corresponding DDL.
|
||||||
|
|
||||||
|
Note - this macro is likely to be deprecated in future in favour of a
|
||||||
|
dedicated "datamodel" folder (prefix mddl)
|
||||||
|
|
||||||
|
Any corresponding data would go in a seperate repo, to avoid this one
|
||||||
|
ballooning in size!
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
|
|
||||||
%mp_coretable(LOCKTABLE,libds=work.locktable)
|
%mp_coretable(LOCKTABLE,libds=work.locktable)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
numbers).
|
numbers).
|
||||||
@param [out] outfile= The output filename - should be quoted.
|
@param [out] outfile= The output filename - should be quoted.
|
||||||
@param [out] outref= (0) The output fileref (takes precedence if provided)
|
@param [out] outref= (0) The output fileref (takes precedence if provided)
|
||||||
@param [in] outencoding= (0) The output encoding to use (unquoted)
|
@param [in] outencoding= (0) The (quoted) output encoding to use, eg `"UTF-8"`
|
||||||
@param [in] termstr= (CRLF) The line seperator to use. For SASJS, will
|
@param [in] termstr= (CRLF) The line seperator to use. For SASJS, will
|
||||||
always be CRLF. Valid values:
|
always be CRLF. Valid values:
|
||||||
@li CRLF
|
@li CRLF
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
%if %index(&ds,.)=0 %then %let ds=WORK.&ds;
|
%if %index(&ds,.)=0 %then %let ds=WORK.&ds;
|
||||||
|
|
||||||
%if &outencoding=0 %then %let outencoding=;
|
%if &outencoding=0 %then %let outencoding=;
|
||||||
%else %let outencoding=encoding="&outencoding";
|
%else %let outencoding=encoding=&outencoding;
|
||||||
|
|
||||||
%if &outref=0 %then %let outloc=&outfile;
|
%if &outref=0 %then %let outloc=&outfile;
|
||||||
%else %let outloc=&outref;
|
%else %let outloc=&outref;
|
||||||
|
|||||||
30
base/mp_ds2ddl.sas
Normal file
30
base/mp_ds2ddl.sas
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief A wrapper for mp_getddl.sas
|
||||||
|
@details In the next release, this will be the main version.
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_getddl.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_ds2ddl(libds,fref=getddl,flavour=SAS,showlog=YES,schema=
|
||||||
|
,applydttm=NO
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
|
%local libref;
|
||||||
|
%let libds=%upcase(&libds);
|
||||||
|
%let libref=%scan(&libds,1,.);
|
||||||
|
%if &libref=&libds %then %let libds=WORK.&libds;
|
||||||
|
|
||||||
|
%mp_getddl(%scan(&libds,1,.)
|
||||||
|
,%scan(&libds,2,.)
|
||||||
|
,fref=&fref
|
||||||
|
,flavour=SAS
|
||||||
|
,showlog=&showlog
|
||||||
|
,schema=&schema
|
||||||
|
,applydttm=&applydttm
|
||||||
|
)
|
||||||
|
|
||||||
|
%mend mp_ds2ddl;
|
||||||
@@ -6,7 +6,8 @@
|
|||||||
SYSCC to 1008 if bad records are found, and call mp_abort.sas for a
|
SYSCC to 1008 if bad records are found, and call mp_abort.sas for a
|
||||||
graceful service exit (configurable).
|
graceful service exit (configurable).
|
||||||
|
|
||||||
Used for dynamic filtering in [Data Controller for SAS®](https://datacontroller.io).
|
Used for dynamic filtering in [Data Controller for SAS®](
|
||||||
|
https://datacontroller.io).
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -125,7 +126,7 @@ data &outds;
|
|||||||
output;
|
output;
|
||||||
end;
|
end;
|
||||||
if OPERATOR_NM not in
|
if OPERATOR_NM not in
|
||||||
('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS')
|
('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS','GE','LE')
|
||||||
then do;
|
then do;
|
||||||
REASON_CD='Invalid OPERATOR_NM: '!!cats(OPERATOR_NM);
|
REASON_CD='Invalid OPERATOR_NM: '!!cats(OPERATOR_NM);
|
||||||
putlog REASON_CD= OPERATOR_NM=;
|
putlog REASON_CD= OPERATOR_NM=;
|
||||||
|
|||||||
@@ -8,8 +8,13 @@
|
|||||||
https://sasapps.io)). This macro is also used in [Data Controller for SAS](
|
https://sasapps.io)). This macro is also used in [Data Controller for SAS](
|
||||||
https://datacontroller.io).
|
https://datacontroller.io).
|
||||||
|
|
||||||
|
A more recent feature of this macro is the ability to support filter queries
|
||||||
|
on Format Catalogs. This is achieved by adding a `-FC` suffix to the `libds`
|
||||||
|
parameter - where the "ds" in this case is the catalog name.
|
||||||
|
|
||||||
@param [in] libds= The target dataset to be filtered (lib should be assigned)
|
|
||||||
|
@param [in] libds= The target dataset to be filtered (lib should be assigned).
|
||||||
|
If filtering a format catalog, add the following suffix: `-FC`.
|
||||||
@param [in] queryds= (WORK.FILTERQUERY) The temporary input query dataset to
|
@param [in] queryds= (WORK.FILTERQUERY) The temporary input query dataset to
|
||||||
be validated. Has the following format:
|
be validated. Has the following format:
|
||||||
|GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
|
|GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
|
||||||
@@ -78,7 +83,10 @@
|
|||||||
%put &sysmacroname entry vars:;
|
%put &sysmacroname entry vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
|
|
||||||
%local ds1 ds2 ds3 ds4 filter_hash;
|
%local ds0 ds1 ds2 ds3 ds4 filter_hash orig_libds;
|
||||||
|
%let libds=%upcase(&libds);
|
||||||
|
%let orig_libds=&libds;
|
||||||
|
|
||||||
%mp_abort(iftrue= (&syscc ne 0)
|
%mp_abort(iftrue= (&syscc ne 0)
|
||||||
,mac=mp_filterstore
|
,mac=mp_filterstore
|
||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
@@ -96,12 +104,49 @@
|
|||||||
,msg=%str(Invalid lock_table value: &lock_table)
|
,msg=%str(Invalid lock_table value: &lock_table)
|
||||||
)
|
)
|
||||||
|
|
||||||
/* validate query */
|
/**
|
||||||
|
* validate query
|
||||||
|
* use format catalog export, if a format
|
||||||
|
*/
|
||||||
|
%if "%substr(&libds,%length(&libds)-2,3)"="-FC" %then %do;
|
||||||
|
%let libds=%scan(&libds,1,-); /* chop off -FC extension */
|
||||||
|
%let ds0=%mf_getuniquename(prefix=fmtds_);
|
||||||
|
/*
|
||||||
|
There is no need to export the entire format catalog here - the validations
|
||||||
|
are done against the data model, not the data values. So we can simply
|
||||||
|
hardcode the structure based on the cntlout dataset.
|
||||||
|
*/
|
||||||
|
proc sql;
|
||||||
|
create table &ds0(
|
||||||
|
FMTNAME char(32)
|
||||||
|
,START char(16)
|
||||||
|
,END char(16)
|
||||||
|
,LABEL char(256)
|
||||||
|
,MIN num length=3
|
||||||
|
,MAX num length=3
|
||||||
|
,DEFAULT num length=3
|
||||||
|
,LENGTH num length=3
|
||||||
|
,FUZZ num
|
||||||
|
,PREFIX char(2)
|
||||||
|
,MULT num
|
||||||
|
,FILL char(1)
|
||||||
|
,NOEDIT num length=3
|
||||||
|
,TYPE char(1)
|
||||||
|
,SEXCL char(1)
|
||||||
|
,EEXCL char(1)
|
||||||
|
,HLO char(13)
|
||||||
|
,DECSEP char(1)
|
||||||
|
,DIG3SEP char(1)
|
||||||
|
,DATATYPE char(8)
|
||||||
|
,LANGUAGE char(8)
|
||||||
|
);
|
||||||
|
%let libds=&ds0;
|
||||||
|
%end;
|
||||||
%mp_filtercheck(&queryds,targetds=&libds,abort=YES)
|
%mp_filtercheck(&queryds,targetds=&libds,abort=YES)
|
||||||
|
|
||||||
/* hash the result */
|
/* hash the result */
|
||||||
%let ds1=%mf_getuniquename(prefix=hashds);
|
%let ds1=%mf_getuniquename(prefix=hashds);
|
||||||
%mp_hashdataset(&queryds,outds=&ds1,salt=&libds)
|
%mp_hashdataset(&queryds,outds=&ds1,salt=&orig_libds)
|
||||||
%let filter_hash=%upcase(%mf_getvalue(&ds1,hashkey));
|
%let filter_hash=%upcase(%mf_getvalue(&ds1,hashkey));
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -132,7 +177,7 @@ run;
|
|||||||
%let ds3=%mf_getuniquename(prefix=filtersum);
|
%let ds3=%mf_getuniquename(prefix=filtersum);
|
||||||
data work.&ds3;
|
data work.&ds3;
|
||||||
if 0 then set &filter_summary;
|
if 0 then set &filter_summary;
|
||||||
filter_table=symget('libds');
|
filter_table="&orig_libds";
|
||||||
filter_hash="&filter_hash";
|
filter_hash="&filter_hash";
|
||||||
PROCESSED_DTTM=%sysfunc(datetime());
|
PROCESSED_DTTM=%sysfunc(datetime());
|
||||||
output;
|
output;
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ create table &outsummary as
|
|||||||
proc format library=&&fmtloc&i CNTLOUT=&tempds;
|
proc format library=&&fmtloc&i CNTLOUT=&tempds;
|
||||||
select &&fmtname&i;
|
select &&fmtname&i;
|
||||||
run;
|
run;
|
||||||
|
data &tempds;
|
||||||
|
length label $256;
|
||||||
|
set &tempds;
|
||||||
|
run;
|
||||||
proc append base=&outdetail data=&tempds;
|
proc append base=&outdetail data=&tempds;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -12,17 +12,19 @@
|
|||||||
|
|
||||||
%mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
|
%mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
|
||||||
|
|
||||||
|
@param [in] contenttype= (TEXTS) Either TEXT, ZIP, CSV, EXCEL
|
||||||
|
@param [in] inloc= /path/to/file.ext to be sent
|
||||||
|
@param [in] inref= fileref of file to be sent (if provided, overrides `inloc`)
|
||||||
|
@param [in] iftrue= (1=1) Provide a condition under which to execute.
|
||||||
|
@param [out] outname= the name of the file, as downloaded by the browser
|
||||||
|
@param [out] outref= (_webout) The destination where the file should be
|
||||||
|
streamed.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getplatform.sas
|
@li mf_getplatform.sas
|
||||||
@li mp_binarycopy.sas
|
@li mp_binarycopy.sas
|
||||||
|
|
||||||
@param contenttype= Either TEXT, ZIP, CSV, EXCEL (default TEXT)
|
|
||||||
@param inloc= /path/to/file.ext to be sent
|
|
||||||
@param inref= fileref of file to be sent (if provided, overrides `inloc`)
|
|
||||||
@param outname= the name of the file, as downloaded by the browser
|
|
||||||
|
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@source https://github.com/sasjs/core
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -30,12 +32,16 @@
|
|||||||
contenttype=TEXT
|
contenttype=TEXT
|
||||||
,inloc=
|
,inloc=
|
||||||
,inref=0
|
,inref=0
|
||||||
|
,iftrue=%str(1=1)
|
||||||
,outname=
|
,outname=
|
||||||
|
,outref=_webout
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%let contentype=%upcase(&contenttype);
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
%local platform; %let platform=%mf_getplatform();
|
|
||||||
|
|
||||||
|
%let contentype=%upcase(&contenttype);
|
||||||
|
%let outref=%upcase(&outref);
|
||||||
|
%local platform; %let platform=%mf_getplatform();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check engine type to avoid the below err message:
|
* check engine type to avoid the below err message:
|
||||||
@@ -44,20 +50,20 @@
|
|||||||
%local streamweb;
|
%local streamweb;
|
||||||
%let streamweb=0;
|
%let streamweb=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set sashelp.vextfl(where=(upcase(fileref)="_WEBOUT"));
|
set sashelp.vextfl(where=(upcase(fileref)="&outref"));
|
||||||
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
if xengine='STREAM' then call symputx('streamweb',1,'l');
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if &contentype=ZIP %then %do;
|
%if &contentype=CSV %then %do;
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
rc=stpsrv_header('Content-type','application/zip');
|
rc=stpsrv_header('Content-type','application/csv');
|
||||||
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
||||||
contenttype='application/zip'
|
contenttype='application/csv'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
@@ -70,11 +76,52 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype='application/vnd.ms-excel'
|
contenttype='application/vnd.ms-excel'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
%else %if &contentype=GIF or &contentype=JPEG or &contentype=PNG %then %do;
|
||||||
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
rc=stpsrv_header('Content-type',"image/%lowcase(&contenttype)");
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
||||||
|
contenttype="image/%lowcase(&contenttype)";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if &contentype=HTML %then %do;
|
||||||
|
%if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
||||||
|
contenttype="text/html";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if &contentype=TEXT %then %do;
|
||||||
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
rc=stpsrv_header('Content-type','application/text');
|
||||||
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
||||||
|
contenttype='application/text'
|
||||||
|
contentdisp="attachment; filename=&outname";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
|
||||||
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
|
data _null_;
|
||||||
|
rc=stpsrv_header('Content-type',"font/%lowcase(&contenttype)");
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %if &platform=SASVIYA %then %do;
|
||||||
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
|
||||||
|
contenttype="font/%lowcase(&contenttype)";
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
%else %if &contentype=XLSX %then %do;
|
%else %if &contentype=XLSX %then %do;
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -84,54 +131,34 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.xls'
|
||||||
contenttype=
|
contenttype=
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %if &contentype=TEXT %then %do;
|
%else %if &contentype=ZIP %then %do;
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
%if &platform=SASMETA and &streamweb=1 %then %do;
|
||||||
data _null_;
|
data _null_;
|
||||||
rc=stpsrv_header('Content-type','application/text');
|
rc=stpsrv_header('Content-type','application/zip');
|
||||||
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if &platform=SASVIYA %then %do;
|
%else %if &platform=SASVIYA %then %do;
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.zip'
|
||||||
contenttype='application/text'
|
contenttype='application/zip'
|
||||||
contentdisp="attachment; filename=&outname";
|
contentdisp="attachment; filename=&outname";
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
%else %if &contentype=CSV %then %do;
|
|
||||||
%if &platform=SASMETA and &streamweb=1 %then %do;
|
|
||||||
data _null_;
|
|
||||||
rc=stpsrv_header('Content-type','application/csv');
|
|
||||||
rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
|
|
||||||
run;
|
|
||||||
%end;
|
|
||||||
%else %if &platform=SASVIYA %then %do;
|
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name='_webout.txt'
|
|
||||||
contenttype='application/csv'
|
|
||||||
contentdisp="attachment; filename=&outname";
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %if &contentype=HTML %then %do;
|
|
||||||
%if &platform=SASVIYA %then %do;
|
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
|
|
||||||
contenttype="text/html";
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
%else %do;
|
%else %do;
|
||||||
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
%put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
|
||||||
%return;
|
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%if &inref ne 0 %then %do;
|
%if &inref ne 0 %then %do;
|
||||||
%mp_binarycopy(inref=&inref,outref=_webout)
|
%mp_binarycopy(inref=&inref,outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%mp_binarycopy(inloc="&inloc",outref=_webout)
|
%mp_binarycopy(inloc="&inloc",outref=&outref)
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mp_streamfile;
|
%mend mp_streamfile;
|
||||||
|
|||||||
@@ -59,7 +59,10 @@
|
|||||||
%&mD.put Executing &sysmacroname..sas;
|
%&mD.put Executing &sysmacroname..sas;
|
||||||
%&mD.put _local_;
|
%&mD.put _local_;
|
||||||
|
|
||||||
%mf_verifymacvars(tree name)
|
%mp_abort(iftrue= (%mf_verifymacvars(tree name)=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: tree name)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check tree exists
|
* check tree exists
|
||||||
|
|||||||
@@ -47,7 +47,10 @@
|
|||||||
%&mD.put Executing &sysmacroname..sas;
|
%&mD.put Executing &sysmacroname..sas;
|
||||||
%&mD.put _local_;
|
%&mD.put _local_;
|
||||||
|
|
||||||
%mf_verifymacvars(tree name)
|
%mp_abort(iftrue= (%mf_verifymacvars(tree name)=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: tree name)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check tree exists
|
* check tree exists
|
||||||
|
|||||||
@@ -133,12 +133,14 @@ run;
|
|||||||
filename &frefin temp;
|
filename &frefin temp;
|
||||||
filename &frefout temp;
|
filename &frefout temp;
|
||||||
|
|
||||||
|
%mp_abort(iftrue= (
|
||||||
|
&engine=BASE & %mf_verifymacvars(libname libref engine servercontext tree)=0
|
||||||
|
)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: libname libref engine servercontext tree)
|
||||||
|
)
|
||||||
|
|
||||||
%if &engine=BASE %then %do;
|
%if &engine=BASE %then %do;
|
||||||
|
|
||||||
%mf_verifymacvars(libname libref engine servercontext tree)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the ServerContext exists
|
* Check that the ServerContext exists
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -108,7 +108,12 @@
|
|||||||
%&mD.put Executing mm_CreateSTP.sas;
|
%&mD.put Executing mm_CreateSTP.sas;
|
||||||
%&mD.put _local_;
|
%&mD.put _local_;
|
||||||
|
|
||||||
%mf_verifymacvars(stpname filename directory tree)
|
%mp_abort(
|
||||||
|
iftrue=(%mf_verifymacvars(stpname filename directory tree)=0)
|
||||||
|
,mac=&sysmacroname
|
||||||
|
,msg=%str(Empty inputs: stpname filename directory tree)
|
||||||
|
)
|
||||||
|
|
||||||
%mp_dropmembers(%scan(&outds,2,.))
|
%mp_dropmembers(%scan(&outds,2,.))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
432
package-lock.json
generated
432
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,7 @@
|
|||||||
"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.6.0"
|
"@sasjs/cli": "3.6.0",
|
||||||
|
"@sasjs/core": "4.4.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
"tests/sas9only"
|
"tests/sas9only"
|
||||||
],
|
],
|
||||||
"programFolders": [],
|
"programFolders": [],
|
||||||
|
"binaryFolders": [],
|
||||||
"deployConfig": {
|
"deployConfig": {
|
||||||
"deployServicePack": true,
|
"deployServicePack": true,
|
||||||
"deployScripts": []
|
"deployScripts": []
|
||||||
|
|||||||
@@ -46,4 +46,20 @@
|
|||||||
),
|
),
|
||||||
desc=Checking tests/macros appLoc matches (which has no subfolder),
|
desc=Checking tests/macros appLoc matches (which has no subfolder),
|
||||||
outds=work.test_results
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(
|
||||||
|
"%mf_getapploc(/some/area/tests/testsetup)"="/some/area"
|
||||||
|
),
|
||||||
|
desc=Checking tests/testsetup operation,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(
|
||||||
|
"%mf_getapploc(/some/area/tests/testteardown)"="/some/area"
|
||||||
|
),
|
||||||
|
desc=Checking tests/teardown operation,
|
||||||
|
outds=work.test_results
|
||||||
)
|
)
|
||||||
22
tests/crossplatform/mf_verifymacvars.test.sas
Normal file
22
tests/crossplatform/mf_verifymacvars.test.sas
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mf_verifymacvars macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_verifymacvars.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%let var1=x;
|
||||||
|
%let var2=y;
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mf_verifymacvars(var1 var2)=1),
|
||||||
|
desc=Checking macvars exist,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
112
tests/crossplatform/mp_filterstore.test.2.sas
Normal file
112
tests/crossplatform/mp_filterstore.test.2.sas
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_filterstore macro with a format catalog
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertdsobs.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
@li mp_coretable.sas
|
||||||
|
@li mp_filterstore.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
libname permlib (work);
|
||||||
|
|
||||||
|
%mp_coretable(LOCKTABLE,libds=permlib.locktable)
|
||||||
|
%mp_coretable(FILTER_SUMMARY,libds=permlib.filtsum)
|
||||||
|
%mp_coretable(FILTER_DETAIL,libds=permlib.filtdet)
|
||||||
|
%mp_coretable(MAXKEYTABLE,libds=permlib.maxkey)
|
||||||
|
|
||||||
|
/* valid filter */
|
||||||
|
data work.inds;
|
||||||
|
infile datalines4 dsd;
|
||||||
|
input GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32.
|
||||||
|
OPERATOR_NM:$12. RAW_VALUE:$4000.;
|
||||||
|
datalines4;
|
||||||
|
AND,AND,1,Start,>,"'2'"
|
||||||
|
AND,AND,1,Fmtname,=,"'MORDOR'"
|
||||||
|
OR,OR,2,Label,IN,"('Dragon1','Dragon2')"
|
||||||
|
OR,OR,2,End,=,"'6'"
|
||||||
|
OR,OR,2,Start,GE,"'10'"
|
||||||
|
;;;;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* make some formats */
|
||||||
|
PROC FORMAT library=permlib.testfmts;
|
||||||
|
picture MyMSdt other='%0Y-%0m-%0dT%0H:%0M:%0S' (datatype=datetime);
|
||||||
|
RUN;
|
||||||
|
data work.fmts;
|
||||||
|
length fmtname $32;
|
||||||
|
do fmtname='SMAUG','MORDOR','GOLLUM';
|
||||||
|
do start=1 to 10;
|
||||||
|
label= cats('Dragon ',start);
|
||||||
|
output;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
proc sort data=work.fmts nodupkey;
|
||||||
|
by fmtname start;
|
||||||
|
run;
|
||||||
|
proc format cntlin=work.fmts library=permlib.testfmts;
|
||||||
|
run;
|
||||||
|
proc format library=permlib.testfmts;
|
||||||
|
invalue indays (default=13) other=42;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mp_filterstore(libds=permlib.testfmts-fc,
|
||||||
|
queryds=work.inds,
|
||||||
|
filter_summary=permlib.filtsum,
|
||||||
|
filter_detail=permlib.filtdet,
|
||||||
|
lock_table=permlib.locktable,
|
||||||
|
maxkeytable=permlib.maxkey,
|
||||||
|
outresult=work.result,
|
||||||
|
outquery=work.query,
|
||||||
|
mdebug=1
|
||||||
|
)
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
%mp_assert(iftrue=(&syscc=0),
|
||||||
|
desc=Ensure macro runs without errors,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
/* ensure only one record created */
|
||||||
|
%mp_assertdsobs(permlib.filtsum,
|
||||||
|
desc=Initial query,
|
||||||
|
test=ATMOST 1,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
/* check RK is correct */
|
||||||
|
proc sql noprint;
|
||||||
|
select max(filter_rk) into: test1 from work.result;
|
||||||
|
%mp_assert(iftrue=(&test1=1),
|
||||||
|
desc=Ensure filter rk is correct,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Test 2 - load same table again and ensure we get the same RK */
|
||||||
|
%mp_filterstore(libds=permlib.testfmts-fc,
|
||||||
|
queryds=work.inds,
|
||||||
|
filter_summary=permlib.filtsum,
|
||||||
|
filter_detail=permlib.filtdet,
|
||||||
|
lock_table=permlib.locktable,
|
||||||
|
maxkeytable=permlib.maxkey,
|
||||||
|
outresult=work.result,
|
||||||
|
outquery=work.query,
|
||||||
|
mdebug=1
|
||||||
|
)
|
||||||
|
/* ensure only one record created */
|
||||||
|
%mp_assertdsobs(permlib.filtsum,
|
||||||
|
desc=Initial query - same obs,
|
||||||
|
test=ATMOST 1,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
/* check RK is correct */
|
||||||
|
proc sql noprint;
|
||||||
|
select max(filter_rk) into: test2 from work.result;
|
||||||
|
%mp_assert(iftrue=(&test2=1),
|
||||||
|
desc=Ensure filter rk is correct for second run,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
28
tests/crossplatform/mp_streamfile.test.sas
Normal file
28
tests/crossplatform/mp_streamfile.test.sas
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_streamfile.sas macro
|
||||||
|
@details This is tricky to test as it streams to webout. For now just
|
||||||
|
check the compilation, and for macro leakage.
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
@li mp_streamfile.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
|
||||||
|
%mp_streamfile(iftrue=(1=0)
|
||||||
|
,contenttype=csv,inloc=/some/where.txt
|
||||||
|
,outname=myfile.txt
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Checking error condition,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
@@ -2,8 +2,18 @@
|
|||||||
@file
|
@file
|
||||||
@brief term file for tests
|
@brief term file for tests
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_assert.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&syscc=0),
|
||||||
|
desc=Checking final error condition,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
%webout(OPEN)
|
%webout(OPEN)
|
||||||
%webout(OBJ, TEST_RESULTS)
|
%webout(OBJ, TEST_RESULTS)
|
||||||
%webout(CLOSE)
|
%webout(CLOSE)
|
||||||
@@ -76,3 +76,6 @@ run;
|
|||||||
iftrue=(&syscc ne 0),
|
iftrue=(&syscc ne 0),
|
||||||
desc=Check that non zero return code is returned if called job fails
|
desc=Check that non zero return code is returned if called job fails
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* set syscc to zero for final check in testterm */
|
||||||
|
%let syscc=0;
|
||||||
Reference in New Issue
Block a user