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

Compare commits

..

7 Commits

Author SHA1 Message Date
Allan Bowe
0fa076cb73 Merge pull request #77 from sasjs/dictfix
fix: ensuring upcase comparisons for dictionary tables
2021-09-27 15:17:48 +03:00
Allan Bowe
6506993704 fix: ensuring upcase comparisons for dictionary tables 2021-09-27 13:04:32 +01:00
Allan Bowe
a69db2ebfb Merge pull request #76 from sasjs/mp_appendfile
feat: mp_appendfile macro for appending 2 or more files together
2021-09-27 14:50:55 +03:00
Allan Bowe
d72ca7cb24 fix: warning in mp_assertcolvals from outobs sql option 2021-09-27 12:30:28 +01:00
Allan Bowe
52dfa7b8f7 feat: mp_appendfile macro for appending 2 or more files together 2021-09-27 11:46:19 +01:00
Allan Bowe
dae03c5730 fix: adding SYSSCPL to mp_abort and webout macros 2021-09-24 17:31:42 +01:00
Allan Bowe
14efe5d3fd chore: removing copyright notice (copy paste error) 2021-09-22 21:10:00 +01:00
14 changed files with 230 additions and 44 deletions

116
all.sas
View File

@@ -1841,6 +1841,7 @@ Usage:
put ",""SYSERRORTEXT"" : " syserrortext; put ",""SYSERRORTEXT"" : " syserrortext;
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
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;
@@ -1855,7 +1856,7 @@ Usage:
%if "&sysprocessmode " = "SAS Stored Process Server " %then %do; %if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
data _null_; data _null_;
putlog 'stpsrvset program error and syscc'; putlog 'stpsrvset program err and syscc';
rc=stpsrvset('program error', 0); rc=stpsrvset('program error', 0);
call symputx("syscc",0,"g"); call symputx("syscc",0,"g");
run; run;
@@ -1901,6 +1902,62 @@ Usage:
%mend mp_abort; %mend mp_abort;
/** @endcond *//** /** @endcond *//**
@file
@brief Append (concatenate) two or more files.
@details Will append one more more `appendrefs` (filerefs) to a `baseref`.
Uses a binary mechanism, so will work with any file type. For that reason -
use with care! And supply your own trailing carriage returns in each file..
Usage:
filename tmp1 temp;
filename tmp2 temp;
filename tmp3 temp;
data _null_; file tmp1; put 'base file';
data _null_; file tmp2; put 'append1';
data _null_; file tmp3; put 'append2';
run;
%mp_appendfile(baseref=tmp1, appendrefs=tmp2 tmp3)
@param [in] baseref= Fileref of the base file (should exist)
@param [in] appendrefs= One or more filerefs to be appended to the base
fileref. Space separated.
@version 9.2
@author Allan Bowe, source: https://github.com/sasjs/core
<h4> SAS Macros </h4>
@li mp_abort.sas
@li mp_binarycopy.sas
**/
%macro mp_appendfile(
baseref=0,
appendrefs=0
)/*/STORE SOURCE*/;
%mp_abort(iftrue= (&baseref=0)
,mac=&sysmacroname
,msg=%str(Baseref NOT specified!)
)
%mp_abort(iftrue= (&appendrefs=0)
,mac=&sysmacroname
,msg=%str(Appendrefs NOT specified!)
)
%local i;
%do i=1 %to %sysfunc(countw(&appendrefs));
%mp_abort(iftrue= (&syscc>0)
,mac=&sysmacroname
,msg=%str(syscc=&syscc)
)
%mp_binarycopy(inref=%scan(&appendrefs,&i), outref=&baseref, mode=APPEND)
%end;
%mend mp_appendfile;/**
@file @file
@brief Generic assertion @brief Generic assertion
@details Useful in the context of writing sasjs tests. The results of the @details Useful in the context of writing sasjs tests. The results of the
@@ -2131,6 +2188,7 @@ Usage:
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mf_existds.sas @li mf_existds.sas
@li mf_getuniquename.sas
@li mf_nobs.sas @li mf_nobs.sas
@li mp_abort.sas @li mp_abort.sas
@@ -2216,13 +2274,25 @@ Usage:
select count(*) into: orig from &lib..&ds; select count(*) into: orig from &lib..&ds;
quit; quit;
%local notfound; %local notfound tmp1 tmp2;
proc sql outobs=10 noprint; %let tmp1=%mf_getuniquename();
select distinct &col into: notfound separated by ' ' %let tmp2=%mf_getuniquename();
/* this is a bit convoluted - but using sql outobs=10 throws warnings */
proc sql noprint;
create view &tmp1 as
select distinct &col
from &lib..&ds from &lib..&ds
where &col not in ( where &col not in (
select &ccol from &clib..&cds select &ccol from &clib..&cds
); );
data &tmp2;
set &tmp1;
if _n_>10 then stop;
run;
proc sql;
select distinct &col into: notfound separated by ' ' from &tmp2;
%mp_abort(iftrue= (&syscc ne 0) %mp_abort(iftrue= (&syscc ne 0)
,mac=&sysmacroname ,mac=&sysmacroname
@@ -3301,8 +3371,8 @@ run;
%let nvars=0; %let nvars=0;
proc sql noprint; proc sql noprint;
select count(*) into: nvars from dictionary.columns select count(*) into: nvars from dictionary.columns
where libname="%scan(%upcase(&base_ds),1)" where upcase(libname)="%scan(%upcase(&base_ds),1)"
and memname="%scan(%upcase(&base_ds),2)"; and upcase(memname)="%scan(%upcase(&base_ds),2)";
%if &nvars=0 %then %do; %if &nvars=0 %then %do;
%put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.; %put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.;
%return; %return;
@@ -3358,8 +3428,8 @@ proc sql
reset outobs=max; reset outobs=max;
create table datalines1 as create table datalines1 as
select name,type,length,varnum,format,label from dictionary.columns select name,type,length,varnum,format,label from dictionary.columns
where libname="%upcase(%scan(&base_ds,1))" where upcase(libname)="%upcase(%scan(&base_ds,1))"
and memname="%upcase(%scan(&base_ds,2))"; and upcase(memname)="%upcase(%scan(&base_ds,2))";
/** /**
Due to long decimals cannot use best. format Due to long decimals cannot use best. format
@@ -4265,8 +4335,6 @@ filename &fref1 clear;
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
@copyright Macro People Ltd - this is a licensed product and
NOT FOR RESALE OR DISTRIBUTION.
**/ **/
@@ -4344,21 +4412,21 @@ run;
/* must use SQL as proc datasets does not support length changes */ /* must use SQL as proc datasets does not support length changes */
proc sql noprint; proc sql noprint;
create table &outds as create table &outds as
select a.TABLE_CATALOG as libref select upcase(a.TABLE_CATALOG) as libref
,a.TABLE_NAME ,upcase(a.TABLE_NAME) as TABLE_NAME
,a.constraint_type ,a.constraint_type
,a.constraint_name ,a.constraint_name
,b.column_name ,b.column_name
from dictionary.TABLE_CONSTRAINTS a from dictionary.TABLE_CONSTRAINTS a
left join dictionary.constraint_column_usage b left join dictionary.constraint_column_usage b
on a.TABLE_CATALOG=b.TABLE_CATALOG on upcase(a.TABLE_CATALOG)=upcase(b.TABLE_CATALOG)
and a.TABLE_NAME=b.TABLE_NAME and upcase(a.TABLE_NAME)=upcase(b.TABLE_NAME)
and a.constraint_name=b.constraint_name and a.constraint_name=b.constraint_name
where a.TABLE_CATALOG="&lib" where upcase(a.TABLE_CATALOG)="&lib"
and b.TABLE_CATALOG="&lib" and upcase(b.TABLE_CATALOG)="&lib"
%if "&ds" ne "" %then %do; %if "&ds" ne "" %then %do;
and a.TABLE_NAME="&ds" and upcase(a.TABLE_NAME)="&ds"
and b.TABLE_NAME="&ds" and upcase(b.TABLE_NAME)="&ds"
%end; %end;
; ;
@@ -4909,7 +4977,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='SQLSVR'; where upcase(libname)="&libref" and engine='SQLSVR';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
%do x=1 %to %sysfunc(countw(&dsnlist)); %do x=1 %to %sysfunc(countw(&dsnlist));
@@ -5002,7 +5070,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='POSTGRES'; where upcase(libname)="&libref" and engine='POSTGRES';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
data _null_; data _null_;
file &fref mod; file &fref mod;
@@ -6104,14 +6172,14 @@ select distinct lowcase(memname)
We take the standard definition one step further by embedding the informat We take the standard definition one step further by embedding the informat
in the table header row, like so: in the table header row, like so:
|var1:$|var2:best.|var3:date9.| |var1:$32|var2:best.|var3:date9.|
|---|---|---| |---|---|---|
|some text|42|01JAN1960| |some text|42|01JAN1960|
|blah|1|31DEC1999| |blah|1|31DEC1999|
Which resolves to: Which resolves to:
|var1:$|var2:best.|var3:date9.| |var1:$32|var2:best.|var3:date9.|
|---|---|---| |---|---|---|
|some text|42|01JAN1960| |some text|42|01JAN1960|
|blah|1|31DEC1999| |blah|1|31DEC1999|
@@ -10060,6 +10128,7 @@ data _null_;
put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; '; put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; ';
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; '; put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
put ' put ",""SYSJOBID"" : ""&sysjobid"" "; '; put ' put ",""SYSJOBID"" : ""&sysjobid"" "; ';
put ' put ",""SYSSCPL"" : ""&sysscpl"" "; ';
put ' put ",""SYSSITE"" : ""&syssite"" "; '; put ' put ",""SYSSITE"" : ""&syssite"" "; ';
put ' sysvlong=quote(trim(symget(''sysvlong''))); '; put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
put ' put '',"SYSVLONG" : '' sysvlong; '; put ' put '',"SYSVLONG" : '' sysvlong; ';
@@ -13555,6 +13624,7 @@ run;
put ",""SYSERRORTEXT"" : ""&syserrortext"" "; put ",""SYSERRORTEXT"" : ""&syserrortext"" ";
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
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;
@@ -15026,6 +15096,7 @@ data _null_;
put ' put ",""SYSCC"" : ""&syscc"" "; '; put ' put ",""SYSCC"" : ""&syscc"" "; ';
put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; '; put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; ';
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; '; put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
put ' put ",""SYSSCPL"" : ""&sysscpl"" "; ';
put ' put ",""SYSSITE"" : ""&syssite"" "; '; put ' put ",""SYSSITE"" : ""&syssite"" "; ';
put ' sysvlong=quote(trim(symget(''sysvlong''))); '; put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
put ' put '',"SYSVLONG" : '' sysvlong; '; put ' put '',"SYSVLONG" : '' sysvlong; ';
@@ -18865,6 +18936,7 @@ filename &fref1 clear;
put ",""SYSCC"" : ""&syscc"" "; put ",""SYSCC"" : ""&syscc"" ";
put ",""SYSERRORTEXT"" : ""&syserrortext"" "; put ",""SYSERRORTEXT"" : ""&syserrortext"" ";
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
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;

View File

@@ -193,6 +193,7 @@
put ",""SYSERRORTEXT"" : " syserrortext; put ",""SYSERRORTEXT"" : " syserrortext;
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
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;
@@ -207,7 +208,7 @@
%if "&sysprocessmode " = "SAS Stored Process Server " %then %do; %if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
data _null_; data _null_;
putlog 'stpsrvset program error and syscc'; putlog 'stpsrvset program err and syscc';
rc=stpsrvset('program error', 0); rc=stpsrvset('program error', 0);
call symputx("syscc",0,"g"); call symputx("syscc",0,"g");
run; run;

57
base/mp_appendfile.sas Normal file
View File

@@ -0,0 +1,57 @@
/**
@file
@brief Append (concatenate) two or more files.
@details Will append one more more `appendrefs` (filerefs) to a `baseref`.
Uses a binary mechanism, so will work with any file type. For that reason -
use with care! And supply your own trailing carriage returns in each file..
Usage:
filename tmp1 temp;
filename tmp2 temp;
filename tmp3 temp;
data _null_; file tmp1; put 'base file';
data _null_; file tmp2; put 'append1';
data _null_; file tmp3; put 'append2';
run;
%mp_appendfile(baseref=tmp1, appendrefs=tmp2 tmp3)
@param [in] baseref= Fileref of the base file (should exist)
@param [in] appendrefs= One or more filerefs to be appended to the base
fileref. Space separated.
@version 9.2
@author Allan Bowe, source: https://github.com/sasjs/core
<h4> SAS Macros </h4>
@li mp_abort.sas
@li mp_binarycopy.sas
**/
%macro mp_appendfile(
baseref=0,
appendrefs=0
)/*/STORE SOURCE*/;
%mp_abort(iftrue= (&baseref=0)
,mac=&sysmacroname
,msg=%str(Baseref NOT specified!)
)
%mp_abort(iftrue= (&appendrefs=0)
,mac=&sysmacroname
,msg=%str(Appendrefs NOT specified!)
)
%local i;
%do i=1 %to %sysfunc(countw(&appendrefs));
%mp_abort(iftrue= (&syscc>0)
,mac=&sysmacroname
,msg=%str(syscc=&syscc)
)
%mp_binarycopy(inref=%scan(&appendrefs,&i), outref=&baseref, mode=APPEND)
%end;
%mend mp_appendfile;

View File

@@ -30,6 +30,7 @@
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mf_existds.sas @li mf_existds.sas
@li mf_getuniquename.sas
@li mf_nobs.sas @li mf_nobs.sas
@li mp_abort.sas @li mp_abort.sas
@@ -115,13 +116,25 @@
select count(*) into: orig from &lib..&ds; select count(*) into: orig from &lib..&ds;
quit; quit;
%local notfound; %local notfound tmp1 tmp2;
proc sql outobs=10 noprint; %let tmp1=%mf_getuniquename();
select distinct &col into: notfound separated by ' ' %let tmp2=%mf_getuniquename();
/* this is a bit convoluted - but using sql outobs=10 throws warnings */
proc sql noprint;
create view &tmp1 as
select distinct &col
from &lib..&ds from &lib..&ds
where &col not in ( where &col not in (
select &ccol from &clib..&cds select &ccol from &clib..&cds
); );
data &tmp2;
set &tmp1;
if _n_>10 then stop;
run;
proc sql;
select distinct &col into: notfound separated by ' ' from &tmp2;
%mp_abort(iftrue= (&syscc ne 0) %mp_abort(iftrue= (&syscc ne 0)
,mac=&sysmacroname ,mac=&sysmacroname

View File

@@ -58,8 +58,8 @@
%let nvars=0; %let nvars=0;
proc sql noprint; proc sql noprint;
select count(*) into: nvars from dictionary.columns select count(*) into: nvars from dictionary.columns
where libname="%scan(%upcase(&base_ds),1)" where upcase(libname)="%scan(%upcase(&base_ds),1)"
and memname="%scan(%upcase(&base_ds),2)"; and upcase(memname)="%scan(%upcase(&base_ds),2)";
%if &nvars=0 %then %do; %if &nvars=0 %then %do;
%put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.; %put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.;
%return; %return;
@@ -115,8 +115,8 @@ proc sql
reset outobs=max; reset outobs=max;
create table datalines1 as create table datalines1 as
select name,type,length,varnum,format,label from dictionary.columns select name,type,length,varnum,format,label from dictionary.columns
where libname="%upcase(%scan(&base_ds,1))" where upcase(libname)="%upcase(%scan(&base_ds,1))"
and memname="%upcase(%scan(&base_ds,2))"; and upcase(memname)="%upcase(%scan(&base_ds,2))";
/** /**
Due to long decimals cannot use best. format Due to long decimals cannot use best. format

View File

@@ -26,8 +26,6 @@
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
@copyright Macro People Ltd - this is a licensed product and
NOT FOR RESALE OR DISTRIBUTION.
**/ **/

View File

@@ -39,21 +39,21 @@
/* must use SQL as proc datasets does not support length changes */ /* must use SQL as proc datasets does not support length changes */
proc sql noprint; proc sql noprint;
create table &outds as create table &outds as
select a.TABLE_CATALOG as libref select upcase(a.TABLE_CATALOG) as libref
,a.TABLE_NAME ,upcase(a.TABLE_NAME) as TABLE_NAME
,a.constraint_type ,a.constraint_type
,a.constraint_name ,a.constraint_name
,b.column_name ,b.column_name
from dictionary.TABLE_CONSTRAINTS a from dictionary.TABLE_CONSTRAINTS a
left join dictionary.constraint_column_usage b left join dictionary.constraint_column_usage b
on a.TABLE_CATALOG=b.TABLE_CATALOG on upcase(a.TABLE_CATALOG)=upcase(b.TABLE_CATALOG)
and a.TABLE_NAME=b.TABLE_NAME and upcase(a.TABLE_NAME)=upcase(b.TABLE_NAME)
and a.constraint_name=b.constraint_name and a.constraint_name=b.constraint_name
where a.TABLE_CATALOG="&lib" where upcase(a.TABLE_CATALOG)="&lib"
and b.TABLE_CATALOG="&lib" and upcase(b.TABLE_CATALOG)="&lib"
%if "&ds" ne "" %then %do; %if "&ds" ne "" %then %do;
and a.TABLE_NAME="&ds" and upcase(a.TABLE_NAME)="&ds"
and b.TABLE_NAME="&ds" and upcase(b.TABLE_NAME)="&ds"
%end; %end;
; ;

View File

@@ -211,7 +211,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='SQLSVR'; where upcase(libname)="&libref" and engine='SQLSVR';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
%do x=1 %to %sysfunc(countw(&dsnlist)); %do x=1 %to %sysfunc(countw(&dsnlist));
@@ -304,7 +304,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='POSTGRES'; where upcase(libname)="&libref" and engine='POSTGRES';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
data _null_; data _null_;
file &fref mod; file &fref mod;

View File

@@ -14,14 +14,14 @@
We take the standard definition one step further by embedding the informat We take the standard definition one step further by embedding the informat
in the table header row, like so: in the table header row, like so:
|var1:$|var2:best.|var3:date9.| |var1:$32|var2:best.|var3:date9.|
|---|---|---| |---|---|---|
|some text|42|01JAN1960| |some text|42|01JAN1960|
|blah|1|31DEC1999| |blah|1|31DEC1999|
Which resolves to: Which resolves to:
|var1:$|var2:best.|var3:date9.| |var1:$32|var2:best.|var3:date9.|
|---|---|---| |---|---|---|
|some text|42|01JAN1960| |some text|42|01JAN1960|
|blah|1|31DEC1999| |blah|1|31DEC1999|

View File

@@ -385,6 +385,7 @@ data _null_;
put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; '; put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; ';
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; '; put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
put ' put ",""SYSJOBID"" : ""&sysjobid"" "; '; put ' put ",""SYSJOBID"" : ""&sysjobid"" "; ';
put ' put ",""SYSSCPL"" : ""&sysscpl"" "; ';
put ' put ",""SYSSITE"" : ""&syssite"" "; '; put ' put ",""SYSSITE"" : ""&syssite"" "; ';
put ' sysvlong=quote(trim(symget(''sysvlong''))); '; put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
put ' put '',"SYSVLONG" : '' sysvlong; '; put ' put '',"SYSVLONG" : '' sysvlong; ';

View File

@@ -155,6 +155,7 @@
put ",""SYSERRORTEXT"" : ""&syserrortext"" "; put ",""SYSERRORTEXT"" : ""&syserrortext"" ";
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
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;

View File

@@ -0,0 +1,41 @@
/**
@file
@brief Testing mp_appendfile.sas macro
<h4> SAS Macros </h4>
@li mp_appendfile.sas
@li mp_assert.sas
**/
filename tmp1 temp;
filename tmp2 temp;
filename tmp3 temp;
data _null_; file tmp1; put 'base file';
data _null_; file tmp2; put 'append1';
data _null_; file tmp3; put 'append2';
run;
%mp_appendfile(baseref=tmp1, appendrefs=tmp2 tmp3)
data _null_;
infile tmp1;
input;
put _infile_;
call symputx(cats('check',_n_),_infile_);
run;
%global check1 check2 check3;
%mp_assert(
iftrue=("&check1"="base file"),
desc=Line 1 of file tmp1 is correct,
outds=work.test_results
)
%mp_assert(
iftrue=("&check2"="append1"),
desc=Line 2 of file tmp1 is correct,
outds=work.test_results
)
%mp_assert(
iftrue=("&check3"="append2"),
desc=Line 3 of file tmp1 is correct,
outds=work.test_results
)

View File

@@ -590,6 +590,7 @@ data _null_;
put ' put ",""SYSCC"" : ""&syscc"" "; '; put ' put ",""SYSCC"" : ""&syscc"" "; ';
put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; '; put ' put ",""SYSERRORTEXT"" : ""&syserrortext"" "; ';
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; '; put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
put ' put ",""SYSSCPL"" : ""&sysscpl"" "; ';
put ' put ",""SYSSITE"" : ""&syssite"" "; '; put ' put ",""SYSSITE"" : ""&syssite"" "; ';
put ' sysvlong=quote(trim(symget(''sysvlong''))); '; put ' sysvlong=quote(trim(symget(''sysvlong''))); ';
put ' put '',"SYSVLONG" : '' sysvlong; '; put ' put '',"SYSVLONG" : '' sysvlong; ';

View File

@@ -215,6 +215,7 @@
put ",""SYSCC"" : ""&syscc"" "; put ",""SYSCC"" : ""&syscc"" ";
put ",""SYSERRORTEXT"" : ""&syserrortext"" "; put ",""SYSERRORTEXT"" : ""&syserrortext"" ";
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
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;