mirror of
https://github.com/sasjs/core.git
synced 2026-01-11 02:50:06 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37076eae89 | ||
|
|
9a9f8dc847 | ||
|
|
719b657267 | ||
|
|
671a615501 | ||
|
|
884b45bf12 | ||
|
|
ff6ae1b066 | ||
|
|
d581fec55e | ||
|
|
a5613a79bb | ||
|
|
c6703e16e8 | ||
|
|
6587dce95b |
@@ -237,6 +237,7 @@ If you find this library useful, please leave a [star](https://github.com/sasjs/
|
|||||||
|
|
||||||
The following repositories are also worth checking out:
|
The following repositories are also worth checking out:
|
||||||
|
|
||||||
|
* [SASJedi/sas-macros](https://github.com/SASJedi/sas-macros)
|
||||||
* [chris-swenson/sasmacros](https://github.com/chris-swenson/sasmacros)
|
* [chris-swenson/sasmacros](https://github.com/chris-swenson/sasmacros)
|
||||||
* [greg-wotton/sas-programs](https://github.com/greg-wootton/sas-programs)
|
* [greg-wotton/sas-programs](https://github.com/greg-wootton/sas-programs)
|
||||||
* [KatjaGlassConsulting/SMILE-SmartSASMacros](https://github.com/KatjaGlassConsulting/SMILE-SmartSASMacros)
|
* [KatjaGlassConsulting/SMILE-SmartSASMacros](https://github.com/KatjaGlassConsulting/SMILE-SmartSASMacros)
|
||||||
|
|||||||
122
all.sas
122
all.sas
@@ -1598,6 +1598,35 @@ Usage:
|
|||||||
&engine
|
&engine
|
||||||
|
|
||||||
%mend mf_getxengine;
|
%mend mf_getxengine;
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Increments a macro variable
|
||||||
|
@details Useful outside of do-loops - will increment a macro variable every
|
||||||
|
time it is called.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
%let cnt=1;
|
||||||
|
%put We have run %mf_increment(cnt) lines;
|
||||||
|
%put Now we have run %mf_increment(cnt) lines;
|
||||||
|
%put There are %mf_increment(cnt) lines in total;
|
||||||
|
|
||||||
|
@param [in] MACRO_NAME the name of the macro variable to increment
|
||||||
|
@param [in] ITER= The amount to add or subtract to the macro
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li mf_increment.test.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mf_increment(macro_name,incr=1);
|
||||||
|
|
||||||
|
/* iterate the value */
|
||||||
|
%let ¯o_name=%eval(&&¯o_name+&incr);
|
||||||
|
/* return the value */
|
||||||
|
&&¯o_name
|
||||||
|
|
||||||
|
%mend mf_increment;
|
||||||
/**
|
/**
|
||||||
@file mf_isblank.sas
|
@file mf_isblank.sas
|
||||||
@brief Checks whether a macro variable is empty (blank)
|
@brief Checks whether a macro variable is empty (blank)
|
||||||
@@ -7149,13 +7178,13 @@ run;
|
|||||||
|
|
||||||
%local x curds;
|
%local x curds;
|
||||||
%if &flavour=SAS %then %do;
|
%if &flavour=SAS %then %do;
|
||||||
data _null_;
|
|
||||||
file &fref mod;
|
|
||||||
put "/* SAS Flavour DDL for %upcase(&libref).&curds */";
|
|
||||||
put "proc sql;";
|
|
||||||
run;
|
|
||||||
%do x=1 %to %sysfunc(countw(&dsnlist));
|
%do x=1 %to %sysfunc(countw(&dsnlist));
|
||||||
%let curds=%scan(&dsnlist,&x);
|
%let curds=%scan(&dsnlist,&x);
|
||||||
|
data _null_;
|
||||||
|
file &fref mod;
|
||||||
|
put "/* SAS Flavour DDL for %upcase(&libref).&curds */";
|
||||||
|
put "proc sql;";
|
||||||
|
run;
|
||||||
data _null_;
|
data _null_;
|
||||||
file &fref mod;
|
file &fref mod;
|
||||||
length lab $1024 typ $20;
|
length lab $1024 typ $20;
|
||||||
@@ -8737,7 +8766,6 @@ options
|
|||||||
if format='' then fmt=cats('$',length,'.');
|
if format='' then fmt=cats('$',length,'.');
|
||||||
else if formatl=0 then fmt=cats(format,'.');
|
else if formatl=0 then fmt=cats(format,'.');
|
||||||
else fmt=cats(format,formatl,'.');
|
else fmt=cats(format,formatl,'.');
|
||||||
newlen=max(formatl,length);
|
|
||||||
end;
|
end;
|
||||||
else do;
|
else do;
|
||||||
typelong='num';
|
typelong='num';
|
||||||
@@ -8745,15 +8773,12 @@ options
|
|||||||
else if formatl=0 then fmt=cats(format,'.');
|
else if formatl=0 then fmt=cats(format,'.');
|
||||||
else if formatd=0 then fmt=cats(format,formatl,'.');
|
else if formatd=0 then fmt=cats(format,formatl,'.');
|
||||||
else fmt=cats(format,formatl,'.',formatd);
|
else fmt=cats(format,formatl,'.',formatd);
|
||||||
/* needs to be wide, for datetimes etc */
|
|
||||||
newlen=max(length,formatl,24);
|
|
||||||
end;
|
end;
|
||||||
/* 32 char unique name */
|
/* 32 char unique name */
|
||||||
newname='sasjs'!!substr(cats(put(md5(name),$hex32.)),1,27);
|
newname='sasjs'!!substr(cats(put(md5(name),$hex32.)),1,27);
|
||||||
|
|
||||||
call symputx(cats('name',_n_),name,'l');
|
call symputx(cats('name',_n_),name,'l');
|
||||||
call symputx(cats('newname',_n_),newname,'l');
|
call symputx(cats('newname',_n_),newname,'l');
|
||||||
call symputx(cats('len',_n_),newlen,'l');
|
|
||||||
call symputx(cats('length',_n_),length,'l');
|
call symputx(cats('length',_n_),length,'l');
|
||||||
call symputx(cats('fmt',_n_),fmt,'l');
|
call symputx(cats('fmt',_n_),fmt,'l');
|
||||||
call symputx(cats('type',_n_),type,'l');
|
call symputx(cats('type',_n_),type,'l');
|
||||||
@@ -8806,7 +8831,8 @@ options
|
|||||||
%end;
|
%end;
|
||||||
));
|
));
|
||||||
%do i=1 %to &numcols;
|
%do i=1 %to &numcols;
|
||||||
length &&name&i $&&len&i;
|
/* formatted values can be up to length 32767 */
|
||||||
|
length &&name&i $32767;
|
||||||
%if &&typelong&i=num %then %do;
|
%if &&typelong&i=num %then %do;
|
||||||
&&name&i=left(put(&&newname&i,&&fmt&i));
|
&&name&i=left(put(&&newname&i,&&fmt&i));
|
||||||
%end;
|
%end;
|
||||||
@@ -15156,7 +15182,6 @@ data _null_;
|
|||||||
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.''); ';
|
put ' else fmt=cats(format,formatl,''.''); ';
|
||||||
put ' newlen=max(formatl,length); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else do; ';
|
put ' else do; ';
|
||||||
put ' typelong=''num''; ';
|
put ' typelong=''num''; ';
|
||||||
@@ -15164,15 +15189,12 @@ data _null_;
|
|||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
||||||
put ' /* needs to be wide, for datetimes etc */ ';
|
|
||||||
put ' newlen=max(length,formatl,24); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' /* 32 char unique name */ ';
|
put ' /* 32 char unique name */ ';
|
||||||
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
||||||
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
||||||
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
||||||
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
||||||
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
||||||
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
||||||
@@ -15225,7 +15247,8 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' )); ';
|
put ' )); ';
|
||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' length &&name&i $&&len&i; ';
|
put ' /* formatted values can be up to length 32767 */ ';
|
||||||
|
put ' length &&name&i $32767; ';
|
||||||
put ' %if &&typelong&i=num %then %do; ';
|
put ' %if &&typelong&i=num %then %do; ';
|
||||||
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
@@ -19093,6 +19116,56 @@ run;
|
|||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mm_webout;
|
%mend mm_webout;
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Creates a metadata folder
|
||||||
|
@details Creates a metadata folder using the batch tools
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%mmx_createmetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_loc.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
@param loc= the metadata folder to delete
|
||||||
|
@param user= username
|
||||||
|
@param pass= password
|
||||||
|
|
||||||
|
@version 9.4
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mmx_createmetafolder(loc=,user=,pass=);
|
||||||
|
|
||||||
|
%local host port path connx_string msg;
|
||||||
|
%let host=%sysfunc(getoption(metaserver));
|
||||||
|
%let port=%sysfunc(getoption(metaport));
|
||||||
|
%let path=%mf_loc(POF)/tools;
|
||||||
|
|
||||||
|
%let connx_string= -host &host -port &port -user '&user' -password '&pass';
|
||||||
|
/* remove directory */
|
||||||
|
data _null_;
|
||||||
|
infile " &path/sas-make-folder &connx_string ""&loc"" -makeFullPath 2>&1"
|
||||||
|
pipe lrecl=10000;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
data _null_; /* check tree exists */
|
||||||
|
length type uri $256;
|
||||||
|
rc=metadata_pathobj("","&loc","Folder",type,uri);
|
||||||
|
call symputx('foldertype',type,'l');
|
||||||
|
run;
|
||||||
|
%let msg=Location (&loc) was not created!!;
|
||||||
|
%mp_abort(iftrue= (&foldertype ne Tree)
|
||||||
|
,mac=&_program..sas
|
||||||
|
,msg=%superq(msg)
|
||||||
|
)
|
||||||
|
|
||||||
|
%mend mmx_createmetafolder;
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Deletes a metadata folder
|
@brief Deletes a metadata folder
|
||||||
@@ -19102,7 +19175,7 @@ run;
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
|
%mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_loc.sas
|
@li mf_loc.sas
|
||||||
@@ -19132,7 +19205,8 @@ data _null_;
|
|||||||
putlog _infile_;
|
putlog _infile_;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%mend mmx_deletemetafolder;/**
|
%mend mmx_deletemetafolder;
|
||||||
|
/**
|
||||||
@file mmx_spkexport.sas
|
@file mmx_spkexport.sas
|
||||||
@brief Exports everything in a particular metadata folder
|
@brief Exports everything in a particular metadata folder
|
||||||
@details Will export everything in a metadata folder to a specified location.
|
@details Will export everything in a metadata folder to a specified location.
|
||||||
@@ -19958,7 +20032,6 @@ data _null_;
|
|||||||
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.''); ';
|
put ' else fmt=cats(format,formatl,''.''); ';
|
||||||
put ' newlen=max(formatl,length); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else do; ';
|
put ' else do; ';
|
||||||
put ' typelong=''num''; ';
|
put ' typelong=''num''; ';
|
||||||
@@ -19966,15 +20039,12 @@ data _null_;
|
|||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
||||||
put ' /* needs to be wide, for datetimes etc */ ';
|
|
||||||
put ' newlen=max(length,formatl,24); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' /* 32 char unique name */ ';
|
put ' /* 32 char unique name */ ';
|
||||||
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
||||||
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
||||||
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
||||||
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
||||||
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
||||||
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
||||||
@@ -20027,7 +20097,8 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' )); ';
|
put ' )); ';
|
||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' length &&name&i $&&len&i; ';
|
put ' /* formatted values can be up to length 32767 */ ';
|
||||||
|
put ' length &&name&i $32767; ';
|
||||||
put ' %if &&typelong&i=num %then %do; ';
|
put ' %if &&typelong&i=num %then %do; ';
|
||||||
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
@@ -22339,7 +22410,6 @@ data _null_;
|
|||||||
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.''); ';
|
put ' else fmt=cats(format,formatl,''.''); ';
|
||||||
put ' newlen=max(formatl,length); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else do; ';
|
put ' else do; ';
|
||||||
put ' typelong=''num''; ';
|
put ' typelong=''num''; ';
|
||||||
@@ -22347,15 +22417,12 @@ data _null_;
|
|||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
||||||
put ' /* needs to be wide, for datetimes etc */ ';
|
|
||||||
put ' newlen=max(length,formatl,24); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' /* 32 char unique name */ ';
|
put ' /* 32 char unique name */ ';
|
||||||
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
||||||
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
||||||
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
||||||
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
||||||
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
||||||
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
||||||
@@ -22408,7 +22475,8 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' )); ';
|
put ' )); ';
|
||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' length &&name&i $&&len&i; ';
|
put ' /* formatted values can be up to length 32767 */ ';
|
||||||
|
put ' length &&name&i $32767; ';
|
||||||
put ' %if &&typelong&i=num %then %do; ';
|
put ' %if &&typelong&i=num %then %do; ';
|
||||||
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
|
|||||||
29
base/mf_increment.sas
Normal file
29
base/mf_increment.sas
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Increments a macro variable
|
||||||
|
@details Useful outside of do-loops - will increment a macro variable every
|
||||||
|
time it is called.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
%let cnt=1;
|
||||||
|
%put We have run %mf_increment(cnt) lines;
|
||||||
|
%put Now we have run %mf_increment(cnt) lines;
|
||||||
|
%put There are %mf_increment(cnt) lines in total;
|
||||||
|
|
||||||
|
@param [in] MACRO_NAME the name of the macro variable to increment
|
||||||
|
@param [in] ITER= The amount to add or subtract to the macro
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li mf_increment.test.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mf_increment(macro_name,incr=1);
|
||||||
|
|
||||||
|
/* iterate the value */
|
||||||
|
%let ¯o_name=%eval(&&¯o_name+&incr);
|
||||||
|
/* return the value */
|
||||||
|
&&¯o_name
|
||||||
|
|
||||||
|
%mend mf_increment;
|
||||||
@@ -130,13 +130,13 @@ run;
|
|||||||
|
|
||||||
%local x curds;
|
%local x curds;
|
||||||
%if &flavour=SAS %then %do;
|
%if &flavour=SAS %then %do;
|
||||||
data _null_;
|
|
||||||
file &fref mod;
|
|
||||||
put "/* SAS Flavour DDL for %upcase(&libref).&curds */";
|
|
||||||
put "proc sql;";
|
|
||||||
run;
|
|
||||||
%do x=1 %to %sysfunc(countw(&dsnlist));
|
%do x=1 %to %sysfunc(countw(&dsnlist));
|
||||||
%let curds=%scan(&dsnlist,&x);
|
%let curds=%scan(&dsnlist,&x);
|
||||||
|
data _null_;
|
||||||
|
file &fref mod;
|
||||||
|
put "/* SAS Flavour DDL for %upcase(&libref).&curds */";
|
||||||
|
put "proc sql;";
|
||||||
|
run;
|
||||||
data _null_;
|
data _null_;
|
||||||
file &fref mod;
|
file &fref mod;
|
||||||
length lab $1024 typ $20;
|
length lab $1024 typ $20;
|
||||||
|
|||||||
@@ -126,7 +126,6 @@
|
|||||||
if format='' then fmt=cats('$',length,'.');
|
if format='' then fmt=cats('$',length,'.');
|
||||||
else if formatl=0 then fmt=cats(format,'.');
|
else if formatl=0 then fmt=cats(format,'.');
|
||||||
else fmt=cats(format,formatl,'.');
|
else fmt=cats(format,formatl,'.');
|
||||||
newlen=max(formatl,length);
|
|
||||||
end;
|
end;
|
||||||
else do;
|
else do;
|
||||||
typelong='num';
|
typelong='num';
|
||||||
@@ -134,15 +133,12 @@
|
|||||||
else if formatl=0 then fmt=cats(format,'.');
|
else if formatl=0 then fmt=cats(format,'.');
|
||||||
else if formatd=0 then fmt=cats(format,formatl,'.');
|
else if formatd=0 then fmt=cats(format,formatl,'.');
|
||||||
else fmt=cats(format,formatl,'.',formatd);
|
else fmt=cats(format,formatl,'.',formatd);
|
||||||
/* needs to be wide, for datetimes etc */
|
|
||||||
newlen=max(length,formatl,24);
|
|
||||||
end;
|
end;
|
||||||
/* 32 char unique name */
|
/* 32 char unique name */
|
||||||
newname='sasjs'!!substr(cats(put(md5(name),$hex32.)),1,27);
|
newname='sasjs'!!substr(cats(put(md5(name),$hex32.)),1,27);
|
||||||
|
|
||||||
call symputx(cats('name',_n_),name,'l');
|
call symputx(cats('name',_n_),name,'l');
|
||||||
call symputx(cats('newname',_n_),newname,'l');
|
call symputx(cats('newname',_n_),newname,'l');
|
||||||
call symputx(cats('len',_n_),newlen,'l');
|
|
||||||
call symputx(cats('length',_n_),length,'l');
|
call symputx(cats('length',_n_),length,'l');
|
||||||
call symputx(cats('fmt',_n_),fmt,'l');
|
call symputx(cats('fmt',_n_),fmt,'l');
|
||||||
call symputx(cats('type',_n_),type,'l');
|
call symputx(cats('type',_n_),type,'l');
|
||||||
@@ -195,7 +191,8 @@
|
|||||||
%end;
|
%end;
|
||||||
));
|
));
|
||||||
%do i=1 %to &numcols;
|
%do i=1 %to &numcols;
|
||||||
length &&name&i $&&len&i;
|
/* formatted values can be up to length 32767 */
|
||||||
|
length &&name&i $32767;
|
||||||
%if &&typelong&i=num %then %do;
|
%if &&typelong&i=num %then %do;
|
||||||
&&name&i=left(put(&&newname&i,&&fmt&i));
|
&&name&i=left(put(&&newname&i,&&fmt&i));
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ data _null_;
|
|||||||
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.''); ';
|
put ' else fmt=cats(format,formatl,''.''); ';
|
||||||
put ' newlen=max(formatl,length); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else do; ';
|
put ' else do; ';
|
||||||
put ' typelong=''num''; ';
|
put ' typelong=''num''; ';
|
||||||
@@ -157,15 +156,12 @@ data _null_;
|
|||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
||||||
put ' /* needs to be wide, for datetimes etc */ ';
|
|
||||||
put ' newlen=max(length,formatl,24); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' /* 32 char unique name */ ';
|
put ' /* 32 char unique name */ ';
|
||||||
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
||||||
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
||||||
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
||||||
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
||||||
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
||||||
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
||||||
@@ -218,7 +214,8 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' )); ';
|
put ' )); ';
|
||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' length &&name&i $&&len&i; ';
|
put ' /* formatted values can be up to length 32767 */ ';
|
||||||
|
put ' length &&name&i $32767; ';
|
||||||
put ' %if &&typelong&i=num %then %do; ';
|
put ' %if &&typelong&i=num %then %do; ';
|
||||||
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
|
|||||||
50
metax/mmx_createmetafolder.sas
Normal file
50
metax/mmx_createmetafolder.sas
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Creates a metadata folder
|
||||||
|
@details Creates a metadata folder using the batch tools
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%mmx_createmetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_loc.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
@param loc= the metadata folder to delete
|
||||||
|
@param user= username
|
||||||
|
@param pass= password
|
||||||
|
|
||||||
|
@version 9.4
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mmx_createmetafolder(loc=,user=,pass=);
|
||||||
|
|
||||||
|
%local host port path connx_string msg;
|
||||||
|
%let host=%sysfunc(getoption(metaserver));
|
||||||
|
%let port=%sysfunc(getoption(metaport));
|
||||||
|
%let path=%mf_loc(POF)/tools;
|
||||||
|
|
||||||
|
%let connx_string= -host &host -port &port -user '&user' -password '&pass';
|
||||||
|
/* remove directory */
|
||||||
|
data _null_;
|
||||||
|
infile " &path/sas-make-folder &connx_string ""&loc"" -makeFullPath 2>&1"
|
||||||
|
pipe lrecl=10000;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
data _null_; /* check tree exists */
|
||||||
|
length type uri $256;
|
||||||
|
rc=metadata_pathobj("","&loc","Folder",type,uri);
|
||||||
|
call symputx('foldertype',type,'l');
|
||||||
|
run;
|
||||||
|
%let msg=Location (&loc) was not created!!;
|
||||||
|
%mp_abort(iftrue= (&foldertype ne Tree)
|
||||||
|
,mac=&_program..sas
|
||||||
|
,msg=%superq(msg)
|
||||||
|
)
|
||||||
|
|
||||||
|
%mend mmx_createmetafolder;
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
%mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
|
%mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_loc.sas
|
@li mf_loc.sas
|
||||||
@@ -37,4 +37,4 @@ data _null_;
|
|||||||
putlog _infile_;
|
putlog _infile_;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%mend mmx_deletemetafolder;
|
%mend mmx_deletemetafolder;
|
||||||
|
|||||||
@@ -25,6 +25,21 @@
|
|||||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||||
<link rel="shortcut icon" href="$relpath^favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="$relpath^favicon.ico" type="image/x-icon" />
|
||||||
$extrastylesheet
|
$extrastylesheet
|
||||||
|
<!-- Matomo -->
|
||||||
|
<script>
|
||||||
|
var _paq = window._paq = window._paq || [];
|
||||||
|
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||||
|
_paq.push(['trackPageView']);
|
||||||
|
_paq.push(['enableLinkTracking']);
|
||||||
|
(function () {
|
||||||
|
var u = "https://analytics.4gl.io/";
|
||||||
|
_paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||||
|
_paq.push(['setSiteId', '6']);
|
||||||
|
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||||
|
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<!-- End Matomo Code -->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -68,4 +83,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ data _null_;
|
|||||||
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.''); ';
|
put ' else fmt=cats(format,formatl,''.''); ';
|
||||||
put ' newlen=max(formatl,length); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else do; ';
|
put ' else do; ';
|
||||||
put ' typelong=''num''; ';
|
put ' typelong=''num''; ';
|
||||||
@@ -158,15 +157,12 @@ data _null_;
|
|||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
||||||
put ' /* needs to be wide, for datetimes etc */ ';
|
|
||||||
put ' newlen=max(length,formatl,24); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' /* 32 char unique name */ ';
|
put ' /* 32 char unique name */ ';
|
||||||
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
||||||
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
||||||
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
||||||
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
||||||
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
||||||
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
||||||
@@ -219,7 +215,8 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' )); ';
|
put ' )); ';
|
||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' length &&name&i $&&len&i; ';
|
put ' /* formatted values can be up to length 32767 */ ';
|
||||||
|
put ' length &&name&i $32767; ';
|
||||||
put ' %if &&typelong&i=num %then %do; ';
|
put ' %if &&typelong&i=num %then %do; ';
|
||||||
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
|
|||||||
35
tests/base/mf_increment.test.sas
Normal file
35
tests/base/mf_increment.test.sas
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mf_increment macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_increment.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%let var=0;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(
|
||||||
|
"%mf_increment(var)"="1"
|
||||||
|
),
|
||||||
|
desc=Checking basic mf_increment usage 1,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(
|
||||||
|
"%mf_increment(var)"="2"
|
||||||
|
),
|
||||||
|
desc=Checking basic mf_increment usage 2,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(
|
||||||
|
"%mf_increment(var,incr=2)"="4"
|
||||||
|
),
|
||||||
|
desc=Checking incr option,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
@@ -292,7 +292,6 @@ data _null_;
|
|||||||
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
put ' if format='''' then fmt=cats(''$'',length,''.''); ';
|
||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.''); ';
|
put ' else fmt=cats(format,formatl,''.''); ';
|
||||||
put ' newlen=max(formatl,length); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else do; ';
|
put ' else do; ';
|
||||||
put ' typelong=''num''; ';
|
put ' typelong=''num''; ';
|
||||||
@@ -300,15 +299,12 @@ data _null_;
|
|||||||
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
put ' else if formatl=0 then fmt=cats(format,''.''); ';
|
||||||
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
put ' else if formatd=0 then fmt=cats(format,formatl,''.''); ';
|
||||||
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
put ' else fmt=cats(format,formatl,''.'',formatd); ';
|
||||||
put ' /* needs to be wide, for datetimes etc */ ';
|
|
||||||
put ' newlen=max(length,formatl,24); ';
|
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' /* 32 char unique name */ ';
|
put ' /* 32 char unique name */ ';
|
||||||
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
put ' newname=''sasjs''!!substr(cats(put(md5(name),$hex32.)),1,27); ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
put ' call symputx(cats(''name'',_n_),name,''l''); ';
|
||||||
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
put ' call symputx(cats(''newname'',_n_),newname,''l''); ';
|
||||||
put ' call symputx(cats(''len'',_n_),newlen,''l''); ';
|
|
||||||
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
put ' call symputx(cats(''length'',_n_),length,''l''); ';
|
||||||
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
put ' call symputx(cats(''fmt'',_n_),fmt,''l''); ';
|
||||||
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
put ' call symputx(cats(''type'',_n_),type,''l''); ';
|
||||||
@@ -361,7 +357,8 @@ data _null_;
|
|||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' )); ';
|
put ' )); ';
|
||||||
put ' %do i=1 %to &numcols; ';
|
put ' %do i=1 %to &numcols; ';
|
||||||
put ' length &&name&i $&&len&i; ';
|
put ' /* formatted values can be up to length 32767 */ ';
|
||||||
|
put ' length &&name&i $32767; ';
|
||||||
put ' %if &&typelong&i=num %then %do; ';
|
put ' %if &&typelong&i=num %then %do; ';
|
||||||
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
put ' &&name&i=left(put(&&newname&i,&&fmt&i)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
|
|||||||
Reference in New Issue
Block a user