mirror of
https://github.com/sasjs/core.git
synced 2026-01-07 01:20:05 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09136cfdbb | ||
|
|
0ca16f3d04 | ||
|
|
1e72f13f2d | ||
|
|
5e8e8e02d3 | ||
|
|
b2e2c7c798 | ||
|
|
b29dd38188 |
213
all.sas
213
all.sas
@@ -4352,6 +4352,103 @@ data _null_;
|
|||||||
run;
|
run;
|
||||||
|
|
||||||
%mend mp_ds2inserts;/**
|
%mend mp_ds2inserts;/**
|
||||||
|
@file
|
||||||
|
@brief Create a Markdown Table from a dataset
|
||||||
|
@details A markdown table is a simple table representation for use in
|
||||||
|
documents written in markdown format.
|
||||||
|
|
||||||
|
An online generator is available here:
|
||||||
|
https://www.tablesgenerator.com/markdown_tables
|
||||||
|
|
||||||
|
This structure is also used by the Macro Core library for documenting input/
|
||||||
|
output datasets, as well as the sasjs/cli tool for documenting inputs/outputs
|
||||||
|
for web services.
|
||||||
|
|
||||||
|
We take the standard definition one step further by embedding the informat
|
||||||
|
in the table header row, like so:
|
||||||
|
|
||||||
|
|var1:$32|var2:best.|var3:date9.|
|
||||||
|
|---|---|---|
|
||||||
|
|some text|42|01JAN1960|
|
||||||
|
|blah|1|31DEC1999|
|
||||||
|
|
||||||
|
Which resolves to:
|
||||||
|
|
||||||
|
|var1:$32|var2:best.|var3:date9.|
|
||||||
|
|---|---|---|
|
||||||
|
|some text|42|01JAN1960|
|
||||||
|
|blah|1|31DEC1999|
|
||||||
|
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%mp_ds2md(sashelp.class)
|
||||||
|
|
||||||
|
@param [in] libds the library / dataset to create or read from.
|
||||||
|
@param [out] outref= (mdtable) Fileref to contain the markdown
|
||||||
|
@param [out] showlog= (YES) Set to NO to avoid printing markdown to the log
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getvarlist.sas
|
||||||
|
@li mf_getvarformat.sas
|
||||||
|
|
||||||
|
@version 9.3
|
||||||
|
@author Allan Bowe
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mp_ds2md(
|
||||||
|
libds,
|
||||||
|
outref=mdtable,
|
||||||
|
showlog=YES
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
|
/* check fileref is assigned */
|
||||||
|
%if %sysfunc(fileref(&outref)) > 0 %then %do;
|
||||||
|
filename &outref temp;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%local vars;
|
||||||
|
%let vars=%upcase(%mf_getvarlist(&libds));
|
||||||
|
|
||||||
|
/* create the header row */
|
||||||
|
data _null_;
|
||||||
|
file &outref;
|
||||||
|
length line $32767;
|
||||||
|
call missing(line);
|
||||||
|
put '|'
|
||||||
|
%local i var fmt;
|
||||||
|
%do i=1 %to %sysfunc(countw(&vars));
|
||||||
|
%let var=%scan(&vars,&i);
|
||||||
|
%let fmt=%lowcase(%mf_getvarformat(&libds,&var,force=1));
|
||||||
|
"&var:&fmt|"
|
||||||
|
%end;
|
||||||
|
;
|
||||||
|
put '|'
|
||||||
|
%do i=1 %to %sysfunc(countw(&vars));
|
||||||
|
"---|"
|
||||||
|
%end;
|
||||||
|
;
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* write out the data */
|
||||||
|
data _null_;
|
||||||
|
file &outref mod dlm='|' lrecl=32767;
|
||||||
|
set &libds ;
|
||||||
|
length line $32767;
|
||||||
|
line='|`'!!cats(%mf_getvarlist(&libds,dlm=%str(%)!!' `|`'!!cats%()))!!' `|';
|
||||||
|
put line;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if %upcase(&showlog)=YES %then %do;
|
||||||
|
options ps=max;
|
||||||
|
data _null_;
|
||||||
|
infile &outref;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend mp_ds2md;/**
|
||||||
@file
|
@file
|
||||||
@brief Checks an input filter table for validity
|
@brief Checks an input filter table for validity
|
||||||
@details Performs checks on the input table to ensure it arrives in the
|
@details Performs checks on the input table to ensure it arrives in the
|
||||||
@@ -5679,7 +5776,7 @@ run;
|
|||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
| | | | |$|F|B|1|0|32767|0|1|0|
|
| | | | |$|F|B|1|0|32767|0|1|0|
|
||||||
| | | | |$|I|B|1|0|32767|0|1|0|
|
| | | | |$|I|B|1|0|32767|0|1|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIANYDT|$ANYDTIF|I|U|1|0|60|0|19|0|
|
|` `|` `|/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIANYDT|$ANYDTIF|I|U|1|0|60|0|19|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFASCII|$ASCII|F|U|1|0|32767|0|1|0|
|
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFASCII|$ASCII|F|U|1|0|32767|0|1|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIASCII|$ASCII|I|U|1|0|32767|0|1|0|
|
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIASCII|$ASCII|I|U|1|0|32767|0|1|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFBASE6|$BASE64X|F|U|1|0|32767|0|1|0|
|
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFBASE6|$BASE64X|F|U|1|0|32767|0|1|0|
|
||||||
@@ -5688,12 +5785,12 @@ run;
|
|||||||
@param [out] outdetail= (0) Provide an output dataset in which to export all
|
@param [out] outdetail= (0) Provide an output dataset in which to export all
|
||||||
the custom format definitions (from proc format CNTLOUT). Definitions:
|
the custom format definitions (from proc format CNTLOUT). Definitions:
|
||||||
https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473477.htm
|
https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473477.htm
|
||||||
Sample data:
|
Sample data:
|
||||||
|
|
||||||
|FMTNAME:$32.|START:$16.|END:$16.|LABEL:$256.|MIN:best.|MAX:best.|DEFAULT:best.|LENGTH:best.|FUZZ:best.|PREFIX:$2.|MULT:best.|FILL:$1.|NOEDIT:best.|TYPE:$1.|SEXCL:$1.|EEXCL:$1.|HLO:$13.|DECSEP:$1.|DIG3SEP:$1.|DATATYPE:$8.|LANGUAGE:$8.|
|
|FMTNAME:$32.|START:$16.|END:$16.|LABEL:$256.|MIN:best.|MAX:best.|DEFAULT:best.|LENGTH:best.|FUZZ:best.|PREFIX:$2.|MULT:best.|FILL:$1.|NOEDIT:best.|TYPE:$1.|SEXCL:$1.|EEXCL:$1.|HLO:$13.|DECSEP:$1.|DIG3SEP:$1.|DATATYPE:$8.|LANGUAGE:$8.|
|
||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
|WHICHPATH|0|0|path1|1|40|28|28|1E-12||0||0|N|N|N| | | | | |
|
|`WHICHPATH `|`0 `|`0 `|`path1 `|`1 `|`40 `|`28 `|`28 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`N `|` `|` `|` `|` `|` `|
|
||||||
|WHICHPATH|`**OTHER**`|`**OTHER**`|big fat problem if not path1|1|40|28|28|1E-12||0||0|N|N|N|O| | | | |
|
|`WHICHPATH `|`**OTHER** `|`**OTHER** `|`big fat problem if not path1 `|`1 `|`40 `|`28 `|`28 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`N `|`O `|` `|` `|` `|` `|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_dedup.sas
|
@li mf_dedup.sas
|
||||||
@@ -7543,13 +7640,13 @@ data &ds1;
|
|||||||
&n1=ranuni(1)*5000000;
|
&n1=ranuni(1)*5000000;
|
||||||
drop &c1 &n1;
|
drop &c1 &n1;
|
||||||
%let charvars=%mf_getvarlist(&libds,typefilter=C);
|
%let charvars=%mf_getvarlist(&libds,typefilter=C);
|
||||||
%do i=1 %to %sysfunc(countw(&charvars));
|
%if &charvars ^= %then %do i=1 %to %sysfunc(countw(&charvars));
|
||||||
%let col=%scan(&charvars,&i);
|
%let col=%scan(&charvars,&i);
|
||||||
&col=subpad(&c1,1,%mf_getvarlen(&libds,&col));
|
&col=subpad(&c1,1,%mf_getvarlen(&libds,&col));
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%let numvars=%mf_getvarlist(&libds,typefilter=N);
|
%let numvars=%mf_getvarlist(&libds,typefilter=N);
|
||||||
%do i=1 %to %sysfunc(countw(&numvars));
|
%if &numvars ^= %then %do i=1 %to %sysfunc(countw(&numvars));
|
||||||
%let col=%scan(&numvars,&i);
|
%let col=%scan(&numvars,&i);
|
||||||
&col=&n1;
|
&col=&n1;
|
||||||
%end;
|
%end;
|
||||||
@@ -7564,104 +7661,6 @@ proc sql;
|
|||||||
drop table &ds1;
|
drop table &ds1;
|
||||||
|
|
||||||
%mend mp_makedata;/**
|
%mend mp_makedata;/**
|
||||||
@file
|
|
||||||
@brief Create a Markdown Table from a dataset
|
|
||||||
@details A markdown table is a simple table representation for use in
|
|
||||||
documents written in markdown format.
|
|
||||||
|
|
||||||
An online generator is available here:
|
|
||||||
https://www.tablesgenerator.com/markdown_tables
|
|
||||||
|
|
||||||
This structure is also used by the Macro Core library for documenting input/
|
|
||||||
output datasets, as well as the sasjs/cli tool for documenting inputs/outputs
|
|
||||||
for web services.
|
|
||||||
|
|
||||||
We take the standard definition one step further by embedding the informat
|
|
||||||
in the table header row, like so:
|
|
||||||
|
|
||||||
|var1:$32|var2:best.|var3:date9.|
|
|
||||||
|---|---|---|
|
|
||||||
|some text|42|01JAN1960|
|
|
||||||
|blah|1|31DEC1999|
|
|
||||||
|
|
||||||
Which resolves to:
|
|
||||||
|
|
||||||
|var1:$32|var2:best.|var3:date9.|
|
|
||||||
|---|---|---|
|
|
||||||
|some text|42|01JAN1960|
|
|
||||||
|blah|1|31DEC1999|
|
|
||||||
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
%mp_mdtablewrite(libds=sashelp.class,showlog=YES)
|
|
||||||
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
|
||||||
@li mf_getvarlist.sas
|
|
||||||
@li mf_getvarformat.sas
|
|
||||||
|
|
||||||
@param [in] libds= the library / dataset to create or read from.
|
|
||||||
@param [out] fref= Fileref to contain the markdown. Default=mdtable.
|
|
||||||
@param [out] showlog= set to YES to show the markdown in the log. Default=NO.
|
|
||||||
|
|
||||||
@version 9.3
|
|
||||||
@author Allan Bowe
|
|
||||||
**/
|
|
||||||
|
|
||||||
%macro mp_mdtablewrite(
|
|
||||||
libds=,
|
|
||||||
fref=mdtable,
|
|
||||||
showlog=NO
|
|
||||||
)/*/STORE SOURCE*/;
|
|
||||||
|
|
||||||
/* check fileref is assigned */
|
|
||||||
%if %sysfunc(fileref(&fref)) > 0 %then %do;
|
|
||||||
filename &fref temp;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%local vars;
|
|
||||||
%let vars=%mf_getvarlist(&libds);
|
|
||||||
|
|
||||||
/* create the header row */
|
|
||||||
data _null_;
|
|
||||||
file &fref;
|
|
||||||
length line $32767;
|
|
||||||
call missing(line);
|
|
||||||
put '|'
|
|
||||||
%local i var fmt;
|
|
||||||
%do i=1 %to %sysfunc(countw(&vars));
|
|
||||||
%let var=%scan(&vars,&i);
|
|
||||||
%let fmt=%mf_getvarformat(&libds,&var,force=1);
|
|
||||||
"&var:&fmt|"
|
|
||||||
%end;
|
|
||||||
;
|
|
||||||
put '|'
|
|
||||||
%do i=1 %to %sysfunc(countw(&vars));
|
|
||||||
"---|"
|
|
||||||
%end;
|
|
||||||
;
|
|
||||||
run;
|
|
||||||
|
|
||||||
/* write out the data */
|
|
||||||
data _null_;
|
|
||||||
file &fref mod dlm='|' lrecl=32767;
|
|
||||||
set &libds ;
|
|
||||||
length line $32767;
|
|
||||||
line=cats('|',%mf_getvarlist(&libds,dlm=%str(,'|',)),'|');
|
|
||||||
put line;
|
|
||||||
run;
|
|
||||||
|
|
||||||
%if %upcase(&showlog)=YES %then %do;
|
|
||||||
options ps=max;
|
|
||||||
data _null_;
|
|
||||||
infile &fref;
|
|
||||||
input;
|
|
||||||
putlog _infile_;
|
|
||||||
run;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%mend mp_mdtablewrite;/**
|
|
||||||
@file
|
@file
|
||||||
@brief Logs the time the macro was executed in a control dataset.
|
@brief Logs the time the macro was executed in a control dataset.
|
||||||
@details If the dataset does not exist, it is created. Usage:
|
@details If the dataset does not exist, it is created. Usage:
|
||||||
@@ -10145,7 +10144,7 @@ run;
|
|||||||
prop='Connection.DBMS.Property.SERVER.Name.xmlKey.txt';
|
prop='Connection.DBMS.Property.SERVER.Name.xmlKey.txt';
|
||||||
rc=metadata_getprop(uri,prop,server,"");
|
rc=metadata_getprop(uri,prop,server,"");
|
||||||
end;
|
end;
|
||||||
if server^='' then server='server='!!server;
|
if server^='' then server='server='!!quote(cats(server));
|
||||||
call symputx('server',server,'l');
|
call symputx('server',server,'l');
|
||||||
|
|
||||||
/* get SCHEMA value */
|
/* get SCHEMA value */
|
||||||
@@ -10291,11 +10290,11 @@ run;
|
|||||||
run;
|
run;
|
||||||
|
|
||||||
%put NOTE: Executing the following:/; %put NOTE-;
|
%put NOTE: Executing the following:/; %put NOTE-;
|
||||||
%put NOTE- libname &libref TERADATA server=&path schema=&schema ;
|
%put NOTE- libname &libref TERADATA server="&path" schema=&schema ;
|
||||||
%put NOTe- authdomain=&authdomain;
|
%put NOTe- authdomain=&authdomain;
|
||||||
%put NOTE-;
|
%put NOTE-;
|
||||||
|
|
||||||
libname &libref TERADATA server=&path schema=&schema authdomain=&authdomain;
|
libname &libref TERADATA server="&path" schema=&schema authdomain=&authdomain;
|
||||||
%end;
|
%end;
|
||||||
%else %if &engine= %then %do;
|
%else %if &engine= %then %do;
|
||||||
%put NOTE: Libref &libref is not registered in metadata;
|
%put NOTE: Libref &libref is not registered in metadata;
|
||||||
|
|||||||
@@ -29,45 +29,44 @@
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%mp_mdtablewrite(libds=sashelp.class,showlog=YES)
|
%mp_ds2md(sashelp.class)
|
||||||
|
|
||||||
|
@param [in] libds the library / dataset to create or read from.
|
||||||
|
@param [out] outref= (mdtable) Fileref to contain the markdown
|
||||||
|
@param [out] showlog= (YES) Set to NO to avoid printing markdown to the log
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getvarlist.sas
|
@li mf_getvarlist.sas
|
||||||
@li mf_getvarformat.sas
|
@li mf_getvarformat.sas
|
||||||
|
|
||||||
@param [in] libds= the library / dataset to create or read from.
|
|
||||||
@param [out] fref= Fileref to contain the markdown. Default=mdtable.
|
|
||||||
@param [out] showlog= set to YES to show the markdown in the log. Default=NO.
|
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mp_mdtablewrite(
|
%macro mp_ds2md(
|
||||||
libds=,
|
libds,
|
||||||
fref=mdtable,
|
outref=mdtable,
|
||||||
showlog=NO
|
showlog=YES
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
/* check fileref is assigned */
|
/* check fileref is assigned */
|
||||||
%if %sysfunc(fileref(&fref)) > 0 %then %do;
|
%if %sysfunc(fileref(&outref)) > 0 %then %do;
|
||||||
filename &fref temp;
|
filename &outref temp;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%local vars;
|
%local vars;
|
||||||
%let vars=%mf_getvarlist(&libds);
|
%let vars=%upcase(%mf_getvarlist(&libds));
|
||||||
|
|
||||||
/* create the header row */
|
/* create the header row */
|
||||||
data _null_;
|
data _null_;
|
||||||
file &fref;
|
file &outref;
|
||||||
length line $32767;
|
length line $32767;
|
||||||
call missing(line);
|
call missing(line);
|
||||||
put '|'
|
put '|'
|
||||||
%local i var fmt;
|
%local i var fmt;
|
||||||
%do i=1 %to %sysfunc(countw(&vars));
|
%do i=1 %to %sysfunc(countw(&vars));
|
||||||
%let var=%scan(&vars,&i);
|
%let var=%scan(&vars,&i);
|
||||||
%let fmt=%mf_getvarformat(&libds,&var,force=1);
|
%let fmt=%lowcase(%mf_getvarformat(&libds,&var,force=1));
|
||||||
"&var:&fmt|"
|
"&var:&fmt|"
|
||||||
%end;
|
%end;
|
||||||
;
|
;
|
||||||
@@ -80,20 +79,20 @@ run;
|
|||||||
|
|
||||||
/* write out the data */
|
/* write out the data */
|
||||||
data _null_;
|
data _null_;
|
||||||
file &fref mod dlm='|' lrecl=32767;
|
file &outref mod dlm='|' lrecl=32767;
|
||||||
set &libds ;
|
set &libds ;
|
||||||
length line $32767;
|
length line $32767;
|
||||||
line=cats('|',%mf_getvarlist(&libds,dlm=%str(,'|',)),'|');
|
line='|`'!!cats(%mf_getvarlist(&libds,dlm=%str(%)!!' `|`'!!cats%()))!!' `|';
|
||||||
put line;
|
put line;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if %upcase(&showlog)=YES %then %do;
|
%if %upcase(&showlog)=YES %then %do;
|
||||||
options ps=max;
|
options ps=max;
|
||||||
data _null_;
|
data _null_;
|
||||||
infile &fref;
|
infile &outref;
|
||||||
input;
|
input;
|
||||||
putlog _infile_;
|
putlog _infile_;
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mp_mdtablewrite;
|
%mend mp_ds2md;
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
| | | | |$|F|B|1|0|32767|0|1|0|
|
| | | | |$|F|B|1|0|32767|0|1|0|
|
||||||
| | | | |$|I|B|1|0|32767|0|1|0|
|
| | | | |$|I|B|1|0|32767|0|1|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIANYDT|$ANYDTIF|I|U|1|0|60|0|19|0|
|
|` `|` `|/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIANYDT|$ANYDTIF|I|U|1|0|60|0|19|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFASCII|$ASCII|F|U|1|0|32767|0|1|0|
|
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFASCII|$ASCII|F|U|1|0|32767|0|1|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIASCII|$ASCII|I|U|1|0|32767|0|1|0|
|
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWIASCII|$ASCII|I|U|1|0|32767|0|1|0|
|
||||||
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFBASE6|$BASE64X|F|U|1|0|32767|0|1|0|
|
| | |/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe|UWFBASE6|$BASE64X|F|U|1|0|32767|0|1|0|
|
||||||
@@ -32,12 +32,12 @@
|
|||||||
@param [out] outdetail= (0) Provide an output dataset in which to export all
|
@param [out] outdetail= (0) Provide an output dataset in which to export all
|
||||||
the custom format definitions (from proc format CNTLOUT). Definitions:
|
the custom format definitions (from proc format CNTLOUT). Definitions:
|
||||||
https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473477.htm
|
https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473477.htm
|
||||||
Sample data:
|
Sample data:
|
||||||
|
|
||||||
|FMTNAME:$32.|START:$16.|END:$16.|LABEL:$256.|MIN:best.|MAX:best.|DEFAULT:best.|LENGTH:best.|FUZZ:best.|PREFIX:$2.|MULT:best.|FILL:$1.|NOEDIT:best.|TYPE:$1.|SEXCL:$1.|EEXCL:$1.|HLO:$13.|DECSEP:$1.|DIG3SEP:$1.|DATATYPE:$8.|LANGUAGE:$8.|
|
|FMTNAME:$32.|START:$16.|END:$16.|LABEL:$256.|MIN:best.|MAX:best.|DEFAULT:best.|LENGTH:best.|FUZZ:best.|PREFIX:$2.|MULT:best.|FILL:$1.|NOEDIT:best.|TYPE:$1.|SEXCL:$1.|EEXCL:$1.|HLO:$13.|DECSEP:$1.|DIG3SEP:$1.|DATATYPE:$8.|LANGUAGE:$8.|
|
||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
|WHICHPATH|0|0|path1|1|40|28|28|1E-12||0||0|N|N|N| | | | | |
|
|`WHICHPATH `|`0 `|`0 `|`path1 `|`1 `|`40 `|`28 `|`28 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`N `|` `|` `|` `|` `|` `|
|
||||||
|WHICHPATH|`**OTHER**`|`**OTHER**`|big fat problem if not path1|1|40|28|28|1E-12||0||0|N|N|N|O| | | | |
|
|`WHICHPATH `|`**OTHER** `|`**OTHER** `|`big fat problem if not path1 `|`1 `|`40 `|`28 `|`28 `|`1E-12 `|` `|`0 `|` `|`0 `|`N `|`N `|`N `|`O `|` `|` `|` `|` `|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_dedup.sas
|
@li mf_dedup.sas
|
||||||
|
|||||||
@@ -62,13 +62,13 @@
|
|||||||
%put output location=&jref;
|
%put output location=&jref;
|
||||||
%if &action=OPEN %then %do;
|
%if &action=OPEN %then %do;
|
||||||
options nobomfile;
|
options nobomfile;
|
||||||
data _null_;file &jref encoding='utf-8';
|
data _null_;file &jref encoding='utf-8' termstr=lf;
|
||||||
put '{"PROCESSED_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '"';
|
put '{"PROCESSED_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '"';
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%else %if (&action=ARR or &action=OBJ) %then %do;
|
%else %if (&action=ARR or &action=OBJ) %then %do;
|
||||||
options validvarname=upcase;
|
options validvarname=upcase;
|
||||||
data _null_;file &jref mod encoding='utf-8';
|
data _null_;file &jref mod encoding='utf-8' termstr=lf;
|
||||||
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
put ", ""%lowcase(%sysfunc(coalescec(&dslabel,&ds)))"":";
|
||||||
|
|
||||||
%if &engine=PROCJSON %then %do;
|
%if &engine=PROCJSON %then %do;
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
run;
|
run;
|
||||||
%let ds=&fmtds;
|
%let ds=&fmtds;
|
||||||
%end; /* &fmt=Y */
|
%end; /* &fmt=Y */
|
||||||
data _null_;file &jref mod encoding='utf-8';
|
data _null_;file &jref mod encoding='utf-8' termstr=lf;
|
||||||
put "["; call symputx('cols',0,'l');
|
put "["; call symputx('cols',0,'l');
|
||||||
proc sort
|
proc sort
|
||||||
data=sashelp.vcolumn(where=(libname='WORK' & memname="%upcase(&ds)"))
|
data=sashelp.vcolumn(where=(libname='WORK' & memname="%upcase(&ds)"))
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
/* write to temp loc to avoid _webout truncation
|
/* write to temp loc to avoid _webout truncation
|
||||||
- https://support.sas.com/kb/49/325.html */
|
- https://support.sas.com/kb/49/325.html */
|
||||||
filename _sjs temp lrecl=131068 encoding='utf-8';
|
filename _sjs temp lrecl=131068 encoding='utf-8';
|
||||||
data _null_; file _sjs lrecl=131068 encoding='utf-8' mod;
|
data _null_; file _sjs lrecl=131068 encoding='utf-8' mod termstr=lf;
|
||||||
set &tempds;
|
set &tempds;
|
||||||
if _n_>1 then put "," @; put
|
if _n_>1 then put "," @; put
|
||||||
%if &action=ARR %then "[" ; %else "{" ;
|
%if &action=ARR %then "[" ; %else "{" ;
|
||||||
@@ -219,14 +219,14 @@
|
|||||||
rc = fclose(fileid);
|
rc = fclose(fileid);
|
||||||
run;
|
run;
|
||||||
filename _sjs clear;
|
filename _sjs clear;
|
||||||
data _null_; file &jref mod encoding='utf-8';
|
data _null_; file &jref mod encoding='utf-8' termstr=lf;
|
||||||
put "]";
|
put "]";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%else %if &action=CLOSE %then %do;
|
%else %if &action=CLOSE %then %do;
|
||||||
data _null_;file &jref encoding='utf-8' mod;
|
data _null_;file &jref encoding='utf-8' mod termstr=lf;
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ data &ds1;
|
|||||||
%end;
|
%end;
|
||||||
|
|
||||||
%let numvars=%mf_getvarlist(&libds,typefilter=N);
|
%let numvars=%mf_getvarlist(&libds,typefilter=N);
|
||||||
%if &numvars ^= %then %do i=1 %to %sysfunc(countw(&numvars));
|
%if &numvars ^= %then %do i=1 %to %sysfunc(countw(&numvars));
|
||||||
%let col=%scan(&numvars,&i);
|
%let col=%scan(&numvars,&i);
|
||||||
&col=&n1;
|
&col=&n1;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ run;
|
|||||||
prop='Connection.DBMS.Property.SERVER.Name.xmlKey.txt';
|
prop='Connection.DBMS.Property.SERVER.Name.xmlKey.txt';
|
||||||
rc=metadata_getprop(uri,prop,server,"");
|
rc=metadata_getprop(uri,prop,server,"");
|
||||||
end;
|
end;
|
||||||
if server^='' then server='server='!!server;
|
if server^='' then server='server='!!quote(cats(server));
|
||||||
call symputx('server',server,'l');
|
call symputx('server',server,'l');
|
||||||
|
|
||||||
/* get SCHEMA value */
|
/* get SCHEMA value */
|
||||||
@@ -441,11 +441,11 @@ run;
|
|||||||
run;
|
run;
|
||||||
|
|
||||||
%put NOTE: Executing the following:/; %put NOTE-;
|
%put NOTE: Executing the following:/; %put NOTE-;
|
||||||
%put NOTE- libname &libref TERADATA server=&path schema=&schema ;
|
%put NOTE- libname &libref TERADATA server="&path" schema=&schema ;
|
||||||
%put NOTe- authdomain=&authdomain;
|
%put NOTe- authdomain=&authdomain;
|
||||||
%put NOTE-;
|
%put NOTE-;
|
||||||
|
|
||||||
libname &libref TERADATA server=&path schema=&schema authdomain=&authdomain;
|
libname &libref TERADATA server="&path" schema=&schema authdomain=&authdomain;
|
||||||
%end;
|
%end;
|
||||||
%else %if &engine= %then %do;
|
%else %if &engine= %then %do;
|
||||||
%put NOTE: Libref &libref is not registered in metadata;
|
%put NOTE: Libref &libref is not registered in metadata;
|
||||||
|
|||||||
@@ -32,7 +32,9 @@
|
|||||||
"name": "viya",
|
"name": "viya",
|
||||||
"serverUrl": "https://sas.analytium.co.uk",
|
"serverUrl": "https://sas.analytium.co.uk",
|
||||||
"serverType": "SASVIYA",
|
"serverType": "SASVIYA",
|
||||||
"allowInsecureRequests": false,
|
"httpsAgentOptions": {
|
||||||
|
"allowInsecureRequests": false
|
||||||
|
},
|
||||||
"appLoc": "/Public/temp/macrocore",
|
"appLoc": "/Public/temp/macrocore",
|
||||||
"macroFolders": [
|
"macroFolders": [
|
||||||
"tests/viyaonly"
|
"tests/viyaonly"
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
OPTIONS NOBOMFILE;
|
OPTIONS NOBOMFILE;
|
||||||
|
|
||||||
/* setup json */
|
/* setup json */
|
||||||
data _null_;file &fref encoding='utf-8';
|
data _null_;file &fref encoding='utf-8' termstr=lf;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
%if %str(&_debug) ge 131 %then %do;
|
||||||
put '>>weboutBEGIN<<';
|
put '>>weboutBEGIN<<';
|
||||||
%end;
|
%end;
|
||||||
@@ -108,14 +108,14 @@
|
|||||||
i+1;
|
i+1;
|
||||||
call symputx('wt'!!left(i),name,'l');
|
call symputx('wt'!!left(i),name,'l');
|
||||||
call symputx('wtcnt',i,'l');
|
call symputx('wtcnt',i,'l');
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
||||||
put ",""WORK"":{";
|
put ",""WORK"":{";
|
||||||
%do i=1 %to &wtcnt;
|
%do i=1 %to &wtcnt;
|
||||||
%let wt=&&wt&i;
|
%let wt=&&wt&i;
|
||||||
proc contents noprint data=&wt
|
proc contents noprint data=&wt
|
||||||
out=_data_ (keep=name type length format:);
|
out=_data_ (keep=name type length format:);
|
||||||
run;%let tempds=%scan(&syslast,2,.);
|
run;%let tempds=%scan(&syslast,2,.);
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
||||||
dsid=open("WORK.&wt",'is');
|
dsid=open("WORK.&wt",'is');
|
||||||
nlobs=attrn(dsid,'NLOBS');
|
nlobs=attrn(dsid,'NLOBS');
|
||||||
nvars=attrn(dsid,'NVARS');
|
nvars=attrn(dsid,'NVARS');
|
||||||
@@ -126,15 +126,15 @@
|
|||||||
put ',"nvars":' nvars;
|
put ',"nvars":' nvars;
|
||||||
%mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
|
%mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=DATASTEP)
|
||||||
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
%mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=DATASTEP)
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
||||||
put "}";
|
put "}";
|
||||||
%end;
|
%end;
|
||||||
data _null_; file &fref mod encoding='utf-8';
|
data _null_; file &fref mod encoding='utf-8' termstr=lf termstr=lf;
|
||||||
put "}";
|
put "}";
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
/* close off json */
|
/* close off json */
|
||||||
data _null_;file &fref mod encoding='utf-8';
|
data _null_;file &fref mod encoding='utf-8' termstr=lf;
|
||||||
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
||||||
@@ -147,7 +147,9 @@
|
|||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
|
put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
|
||||||
put ",""SYSPROCESSMODE"" : ""&SYSPROCESSMODE"" ";
|
put ",""SYSPROCESSMODE"" : ""&SYSPROCESSMODE"" ";
|
||||||
put ",""SYSPROCESSNAME"" : ""&SYSPROCESSNAME"" ";
|
length SYSPROCESSNAME $512;
|
||||||
|
SYSPROCESSNAME=quote(urlencode(cats(SYSPROCESSNAME)));
|
||||||
|
put ",""SYSPROCESSNAME"" : " SYSPROCESSNAME;
|
||||||
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
||||||
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
||||||
put ",""SYSSITE"" : ""&syssite"" ";
|
put ",""SYSSITE"" : ""&syssite"" ";
|
||||||
@@ -156,7 +158,8 @@
|
|||||||
put ',"SYSVLONG" : ' sysvlong;
|
put ',"SYSVLONG" : ' sysvlong;
|
||||||
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
|
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
|
||||||
autoexec=quote(trim(getoption('autoexec')));
|
length autoexec $512;
|
||||||
|
autoexec=quote(urlencode(trim(getoption('autoexec'))));
|
||||||
put ',"AUTOEXEC" : ' autoexec;
|
put ',"AUTOEXEC" : ' autoexec;
|
||||||
memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
|
memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
|
||||||
memsize=quote(cats(memsize));
|
memsize=quote(cats(memsize));
|
||||||
|
|||||||
34
tests/crossplatform/mp_ds2md.test.sas
Normal file
34
tests/crossplatform/mp_ds2md.test.sas
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mp_ds2md.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mp_ds2md.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%mp_ds2md(sashelp.class,outref=md)
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
infile md;
|
||||||
|
input;
|
||||||
|
call symputx(cats('test',_n_),_infile_);
|
||||||
|
if _n_=4 then stop;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test1"="|NAME:$8.|SEX:$1.|AGE:best.|HEIGHT:best.|WEIGHT:best.|"),
|
||||||
|
desc=Checking header row,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test2"="|---|---|---|---|---|"),
|
||||||
|
desc=Checking divider row,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test3"="|`Alfred `|`M `|`14 `|`69 `|`112.5 `|"),
|
||||||
|
desc=Checking data row,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user