mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-14 10:00:05 +00:00
spelling
This commit is contained in:
Binary file not shown.
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Internal macro called by dsSQL() function.
|
* Internal macro called by dsSQL() function.
|
||||||
*
|
*
|
||||||
* Recomnended for SAS 9.3 and higher.
|
* Recommended for SAS 9.3 and higher.
|
||||||
* Based on paper:
|
* Based on paper:
|
||||||
* "Use the Full Power of SAS in Your Function-Style Macros"
|
* "Use the Full Power of SAS in Your Function-Style Macros"
|
||||||
* by Mike Rhoads, Westat, Rockville, MD
|
* by Mike Rhoads, Westat, Rockville, MD
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
*
|
*
|
||||||
* Main macro which allows to use
|
* Main macro which allows to use
|
||||||
* SQL's queries in the data step.
|
* SQL's queries in the data step.
|
||||||
* Recomnended for SAS 9.3 and higher.
|
* Recommended for SAS 9.3 and higher.
|
||||||
* Based on paper:
|
* Based on paper:
|
||||||
* "Use the Full Power of SAS in Your Function-Style Macros"
|
* "Use the Full Power of SAS in Your Function-Style Macros"
|
||||||
* by Mike Rhoads, Westat, Rockville, MD
|
* by Mike Rhoads, Westat, Rockville, MD
|
||||||
* https://support.sas.com/resources/papers/proceedings12/004-2012.pdf
|
* https://support.sas.com/resources/papers/proceedings12/004-2012.pdf
|
||||||
*
|
*
|
||||||
* EXAMPLE 1: simple sql querry
|
* EXAMPLE 1: simple sql query
|
||||||
|
|
||||||
data class_subset;
|
data class_subset;
|
||||||
set %SQL(select name, sex, height from sashelp.class where age > 12);
|
set %SQL(select name, sex, height from sashelp.class where age > 12);
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
%let SYSPBUFF = %substr(&SYSPBUFF, 2, %LENGTH(&SYSPBUFF) - 2); /* remove brackets */
|
%let SYSPBUFF = %substr(&SYSPBUFF, 2, %LENGTH(&SYSPBUFF) - 2); /* remove brackets */
|
||||||
%let SYSPBUFF = %superq(SYSPBUFF); /* macroquoting */
|
%let SYSPBUFF = %superq(SYSPBUFF); /* macroquoting */
|
||||||
%let SYSPBUFF = %sysfunc(quote(&SYSPBUFF)); /* quotes */
|
%let SYSPBUFF = %sysfunc(quote(&SYSPBUFF)); /* quotes */
|
||||||
%put NOTE-***the querry***; /* print out the querry in the log */
|
%put NOTE-***the query***; /* print out the query in the log */
|
||||||
%put NOTE-&SYSPBUFF.;
|
%put NOTE-&SYSPBUFF.;
|
||||||
%put NOTE-****************;
|
%put NOTE-****************;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Internal function called by %SQL() macro.
|
* Internal function called by %SQL() macro.
|
||||||
*
|
*
|
||||||
* Recomnended for SAS 9.3 and higher.
|
* Recommended for SAS 9.3 and higher.
|
||||||
* Based on paper:
|
* Based on paper:
|
||||||
* "Use the Full Power of SAS in Your Function-Style Macros"
|
* "Use the Full Power of SAS in Your Function-Style Macros"
|
||||||
* by Mike Rhoads, Westat, Rockville, MD
|
* by Mike Rhoads, Westat, Rockville, MD
|
||||||
@@ -20,7 +20,7 @@ proc fcmp
|
|||||||
;
|
;
|
||||||
function dsSQL(unique_index_2, query $) $ 41;
|
function dsSQL(unique_index_2, query $) $ 41;
|
||||||
length
|
length
|
||||||
query query_arg $ 32000 /* max querry length */
|
query query_arg $ 32000 /* max query length */
|
||||||
viewname $ 41
|
viewname $ 41
|
||||||
;
|
;
|
||||||
query_arg = dequote(query);
|
query_arg = dequote(query);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* This is the description file for the package. */
|
/* This is the description file for the package. */
|
||||||
/* The collon (:) is a field separator and is restricted */
|
/* The colon (:) is a field separator and is restricted */
|
||||||
/* in lines of the header part. */
|
/* in lines of the header part. */
|
||||||
|
|
||||||
/* **HEADER** */
|
/* **HEADER** */
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ ods html;
|
|||||||
/*
|
/*
|
||||||
* filename reference "packages" and "package" are keywords;
|
* filename reference "packages" and "package" are keywords;
|
||||||
* the first one should be used to point folder with packages;
|
* the first one should be used to point folder with packages;
|
||||||
* the second is used internaly by macros;
|
* the second is used internally by macros;
|
||||||
|
|
||||||
filename packages "C:\SAS_PACKAGES";
|
filename packages "C:\SAS_PACKAGES";
|
||||||
%include packages(loadpackage.sas);
|
%include packages(loadpackage.sas);
|
||||||
|
|||||||
Binary file not shown.
@@ -36,11 +36,11 @@
|
|||||||
*/
|
*/
|
||||||
/**#############################################################################**/
|
/**#############################################################################**/
|
||||||
|
|
||||||
/* Macros to generte SAS packages */
|
/* Macros to generate SAS packages */
|
||||||
/* A SAS package is a zip file containing a group
|
/* A SAS package is a zip file containing a group
|
||||||
of SAS codes (macros, functions, datasteps generating
|
of SAS codes (macros, functions, datasteps generating
|
||||||
data, etc.) wrapped up together and %INCLUDEed by
|
data, etc.) wrapped up together and %INCLUDEed by
|
||||||
a single load.sas file (also embeaded inside the zip).
|
a single load.sas file (also embedded inside the zip).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
@@ -92,7 +92,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 256;
|
|||||||
when(upcase(scan(_INFILE_, 1, ":")) = "REQUIRED") call symputX("packageRequired", scan(_INFILE_, 2, ":"),"L");
|
when(upcase(scan(_INFILE_, 1, ":")) = "REQUIRED") call symputX("packageRequired", scan(_INFILE_, 2, ":"),"L");
|
||||||
when(upcase(scan(_INFILE_, 1, ":")) = "REQPACKAGES") call symputX("packageReqPackages", scan(_INFILE_, 2, ":"),"L");
|
when(upcase(scan(_INFILE_, 1, ":")) = "REQPACKAGES") call symputX("packageReqPackages", scan(_INFILE_, 2, ":"),"L");
|
||||||
|
|
||||||
/* stop at the begining of description */
|
/* stop at the beginning of description */
|
||||||
when(upcase(scan(_INFILE_, 1, ":")) = "DESCRIPTION START") stop;
|
when(upcase(scan(_INFILE_, 1, ":")) = "DESCRIPTION START") stop;
|
||||||
otherwise;
|
otherwise;
|
||||||
end;
|
end;
|
||||||
@@ -125,7 +125,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 256;
|
|||||||
%do;
|
%do;
|
||||||
%put ERROR: Package name is more than 24 characters long.;
|
%put ERROR: Package name is more than 24 characters long.;
|
||||||
%put ERROR- The name is used for functions%str(%') dataset name;
|
%put ERROR- The name is used for functions%str(%') dataset name;
|
||||||
%put ERROR- and for formats%str(%') catalog name (with sufix).;
|
%put ERROR- and for formats%str(%') cataloge name (with suffix).;
|
||||||
%put ERROR- The length is %sysfunc(lengthn(&packageName.)). Try something shorter.;
|
%put ERROR- The length is %sysfunc(lengthn(&packageName.)). Try something shorter.;
|
||||||
%abort;
|
%abort;
|
||||||
%end;
|
%end;
|
||||||
@@ -139,7 +139,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 256;
|
|||||||
%do;
|
%do;
|
||||||
%put ERROR: Package name contains illegal symbols.;
|
%put ERROR: Package name contains illegal symbols.;
|
||||||
%put ERROR- The name is used for functions%str(%') dataset name;
|
%put ERROR- The name is used for functions%str(%') dataset name;
|
||||||
%put ERROR- and for formats%str(%') catalog name.;
|
%put ERROR- and for formats%str(%') cataloge name.;
|
||||||
%put ERROR- Only English letters, underscore(_), and digits are allowed.;
|
%put ERROR- Only English letters, underscore(_), and digits are allowed.;
|
||||||
%put ERROR- Try something else. Maybe: %qsysfunc(compress(&packageName.,,KDF)) will do?;
|
%put ERROR- Try something else. Maybe: %qsysfunc(compress(&packageName.,,KDF)) will do?;
|
||||||
%abort;
|
%abort;
|
||||||
@@ -181,7 +181,7 @@ filename &zipReferrence. ZIP "&filesLocation./%lowcase(&packageName.).zip";
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
Remember to prepare the description.sas file for you package.
|
Remember to prepare the description.sas file for you package.
|
||||||
The collon (:) is a field separator and is restricted
|
The colon (:) is a field separator and is restricted
|
||||||
in lines of the header part.
|
in lines of the header part.
|
||||||
The file should contain the following obligatory information:
|
The file should contain the following obligatory information:
|
||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
@@ -210,7 +210,7 @@ DESCRIPTION END:
|
|||||||
Name of the 'type' of folder and files.sas inside must be in _low_ case letters.
|
Name of the 'type' of folder and files.sas inside must be in _low_ case letters.
|
||||||
|
|
||||||
If order of loading is important, the 'sequential number'
|
If order of loading is important, the 'sequential number'
|
||||||
can be used to order multiple types in the wey you wish.
|
can be used to order multiple types in the way you wish.
|
||||||
|
|
||||||
The "tree structure" of the folder could be for example as follows:
|
The "tree structure" of the folder could be for example as follows:
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ DESCRIPTION END:
|
|||||||
| |
|
| |
|
||||||
| +-<no file, in this case folder may be skipped>
|
| +-<no file, in this case folder may be skipped>
|
||||||
|
|
|
|
||||||
+-006_format [if your codes depend eachother you can order them in folders,
|
+-006_format [if your codes depend each other you can order them in folders,
|
||||||
| | e.g. code from 003_... will be executed before 006_...]
|
| | e.g. code from 003_... will be executed before 006_...]
|
||||||
| |
|
| |
|
||||||
| +-abc.sas [a file with a code creating format ABC,
|
| +-abc.sas [a file with a code creating format ABC,
|
||||||
@@ -605,7 +605,7 @@ data _null_;
|
|||||||
isFunction + (upcase(type)=:'FUNCTION');
|
isFunction + (upcase(type)=:'FUNCTION');
|
||||||
isFormat + (upcase(type)=:'FORMAT');
|
isFormat + (upcase(type)=:'FORMAT');
|
||||||
|
|
||||||
/* add the link to the functions' dataset, only for the first occurence */
|
/* add the link to the functions' dataset, only for the first occurrence */
|
||||||
if 1 = isFunction and (upcase(type)=:'FUNCTION') then
|
if 1 = isFunction and (upcase(type)=:'FUNCTION') then
|
||||||
do;
|
do;
|
||||||
put "options APPEND=(cmplib = work.%lowcase(&packageName.fcmp));";
|
put "options APPEND=(cmplib = work.%lowcase(&packageName.fcmp));";
|
||||||
@@ -613,7 +613,7 @@ data _null_;
|
|||||||
put '%put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /;
|
put '%put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
/* add the link to the formats' catalog, only for the first occurence */
|
/* add the link to the formats' catalog, only for the first occurrence */
|
||||||
if 1 = isFormat and (upcase(type)=:'FORMAT') then
|
if 1 = isFormat and (upcase(type)=:'FORMAT') then
|
||||||
do;
|
do;
|
||||||
put "options INSERT=( fmtsearch = work.%lowcase(&packageName.format) );";
|
put "options INSERT=( fmtsearch = work.%lowcase(&packageName.format) );";
|
||||||
@@ -935,7 +935,7 @@ data _null_;
|
|||||||
put ' set WORK._last_ end = EOFDS nobs = NOBS; ';
|
put ' set WORK._last_ end = EOFDS nobs = NOBS; ';
|
||||||
put ' length memberX $ 1024; ';
|
put ' length memberX $ 1024; ';
|
||||||
put ' memberX = cats("_",folder,".",file); ';
|
put ' memberX = cats("_",folder,".",file); ';
|
||||||
/* inner datastep in call execute to read each embedaded file */
|
/* inner datastep in call execute to read each embedded file */
|
||||||
put ' call execute("data _null_; ");';
|
put ' call execute("data _null_; ");';
|
||||||
put ' call execute("infile package(" || strip(memberX) || ") end = EOF; ");';
|
put ' call execute("infile package(" || strip(memberX) || ") end = EOF; ");';
|
||||||
put ' call execute(" printer = 0; ");';
|
put ' call execute(" printer = 0; ");';
|
||||||
@@ -1028,6 +1028,10 @@ TODO:
|
|||||||
- dodac typ "iml", "ds2", "proto"
|
- dodac typ "iml", "ds2", "proto"
|
||||||
|
|
||||||
-lista wymaganych komponentow potrzebnych do działania SASa (na bazie proc SETINIT) [v]
|
-lista wymaganych komponentow potrzebnych do działania SASa (na bazie proc SETINIT) [v]
|
||||||
|
|
||||||
|
-sparwdzanie domknietosci, parzystosci i wystepowania tagow HELP START - HELP END w plikach [ ]
|
||||||
|
|
||||||
|
-weryfikacja nadpisywania makr [ ]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/**############################################################################**/
|
/**############################################################################**/
|
||||||
/* */
|
/* */
|
||||||
/* Copyright Bartosz Jablonski, Jully 2019. */
|
/* Copyright Bartosz Jablonski, July 2019. */
|
||||||
/* */
|
/* */
|
||||||
/* Code is free and open source. If you want - you can use it. */
|
/* Code is free and open source. If you want - you can use it. */
|
||||||
/* I tested it the best I could */
|
/* I tested it the best I could */
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
*/
|
*/
|
||||||
/**#############################################################################**/
|
/**#############################################################################**/
|
||||||
|
|
||||||
/* Macros to list SAS packages in packsges' folder */
|
/* Macros to list SAS packages in packages' folder */
|
||||||
/* A SAS package is a zip file containing a group
|
/* A SAS package is a zip file containing a group
|
||||||
of SAS codes (macros, functions, datasteps generating
|
of SAS codes (macros, functions, datasteps generating
|
||||||
data, etc.) wrapped up together and %INCLUDEed by
|
data, etc.) wrapped up together and %INCLUDEed by
|
||||||
a single load.sas file (also embeaded inside the zip).
|
a single load.sas file (also embedded inside the zip).
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Example 1:
|
* Example 1:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/**############################################################################**/
|
/**############################################################################**/
|
||||||
/* */
|
/* */
|
||||||
/* Copyright Bartosz Jablonski, Jully 2019. */
|
/* Copyright Bartosz Jablonski, July 2019. */
|
||||||
/* */
|
/* */
|
||||||
/* Code is free and open source. If you want - you can use it. */
|
/* Code is free and open source. If you want - you can use it. */
|
||||||
/* I tested it the best I could */
|
/* I tested it the best I could */
|
||||||
@@ -40,11 +40,11 @@
|
|||||||
/* A SAS package is a zip file containing a group
|
/* A SAS package is a zip file containing a group
|
||||||
of SAS codes (macros, functions, datasteps generating
|
of SAS codes (macros, functions, datasteps generating
|
||||||
data, etc.) wrapped up together and %INCLUDEed by
|
data, etc.) wrapped up together and %INCLUDEed by
|
||||||
a single load.sas file (also embeaded inside the zip).
|
a single load.sas file (also embedded inside the zip).
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
TODO:
|
TODO:
|
||||||
- makro for testing avaliable packages in the packages' folder [DONE] checkuot: %listPackages()
|
- macro for testing available packages in the packages' folder [DONE] checkout: %listPackages()
|
||||||
*/
|
*/
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
|
|
||||||
@@ -198,12 +198,12 @@ TODO:
|
|||||||
/*
|
/*
|
||||||
* Filenames references "packages" and "package" are keywords;
|
* Filenames references "packages" and "package" are keywords;
|
||||||
* the first one should be used to point folder with packages;
|
* the first one should be used to point folder with packages;
|
||||||
* the second is used internaly by macros;
|
* the second is used internally by macros;
|
||||||
|
|
||||||
* Example 1:
|
* Example 1:
|
||||||
* assuming that _THIS_FILE_ and the SQLinDS package (sqlinds.zip file)
|
* assuming that _THIS_FILE_ and the SQLinDS package (sqlinds.zip file)
|
||||||
* are located in the "C:/SAS_PACKAGES/" folder
|
* are located in the "C:/SAS_PACKAGES/" folder
|
||||||
* coppy the following code into autoexec.sas
|
* copy the following code into autoexec.sas
|
||||||
* or run it in your SAS session
|
* or run it in your SAS session
|
||||||
**/
|
**/
|
||||||
/*
|
/*
|
||||||
|
|||||||
BIN
macroarray.zip
BIN
macroarray.zip
Binary file not shown.
BIN
sqlinds.zip
BIN
sqlinds.zip
Binary file not shown.
Reference in New Issue
Block a user