diff --git a/SQLinDS/000_libname/dssql.sas b/SQLinDS/000_libname/dssql.sas index 7d5b339..8b520bf 100644 --- a/SQLinDS/000_libname/dssql.sas +++ b/SQLinDS/000_libname/dssql.sas @@ -3,12 +3,12 @@ /* >>> dsSQL library: <<< * * The dsSQL library stores temporary views - * generated during %SQL() macro's execution. - * If possible, created as a subdirectory of WORK: + * generated during the %SQL() macro execution. + * If possible a subdirectory of WORK is created as: LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp"; - * if not then redirected to WORK + * if not possible then redirects to WORK as: LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))"; @@ -25,6 +25,5 @@ data _null_; rc1 = LIBNAME("dsSQL", "%sysfunc(pathname(work))", "BASE"); run; +/* list details about the library in the log */ libname dsSQL LIST; -; - diff --git a/SQLinDS/001_macro/dssql_inner.sas b/SQLinDS/001_macro/dssql_inner.sas index 7a7f896..31c78f8 100644 --- a/SQLinDS/001_macro/dssql_inner.sas +++ b/SQLinDS/001_macro/dssql_inner.sas @@ -1,8 +1,10 @@ -/*** HELP START ***/ +/*** HELP START ***/ /* >>> %dsSQL_Inner() macro: <<< * - * Internal macro called by dsSQL() function. + * Internal macro called by dsSQL() function. + * The macro generates a uniqualy named sql view on the fly + * which is stored in DSSQL library. * * Recommended for SAS 9.3 and higher. * Based on paper: diff --git a/SQLinDS/001_macro/sql.sas b/SQLinDS/001_macro/sql.sas index 119a129..67f0ecf 100644 --- a/SQLinDS/001_macro/sql.sas +++ b/SQLinDS/001_macro/sql.sas @@ -10,13 +10,19 @@ * by Mike Rhoads, Westat, Rockville, MD * https://support.sas.com/resources/papers/proceedings12/004-2012.pdf * + * SYNTAX: + + %sql() + + * The sql querry code is limited to 32000 bytes. + * * EXAMPLE 1: simple sql query data class_subset; set %SQL(select name, sex, height from sashelp.class where age > 12); run; - * EXAMPLE 2: with dataset options + * EXAMPLE 2: query with dataset options data renamed; set %SQL(select * from sashelp.class where sex = "F")(rename = (age=age2)); @@ -33,15 +39,15 @@ /*** HELP END ***/ -/* outer macro */ +/* Main User macro */ %MACRO SQL() / PARMBUFF SECURE; %let SYSPBUFF = %superq(SYSPBUFF); /* macroquoting */ %let SYSPBUFF = %substr(&SYSPBUFF, 2, %LENGTH(&SYSPBUFF) - 2); /* remove brackets */ %let SYSPBUFF = %superq(SYSPBUFF); /* macroquoting */ %let SYSPBUFF = %sysfunc(quote(&SYSPBUFF)); /* quotes */ - %put NOTE-***the query***; /* print out the query in the log */ + %put NOTE:*** the query ***; /* print out the query in the log */ %put NOTE-&SYSPBUFF.; - %put NOTE-****************; + %put NOTE-*****************; %local UNIQUE_INDEX; /* internal variable, a unique index for views */ %let UNIQUE_INDEX = &SYSINDEX; diff --git a/SQLinDS/002_function/dssql.sas b/SQLinDS/002_function/dssql.sas index d70594e..da6ffd3 100644 --- a/SQLinDS/002_function/dssql.sas +++ b/SQLinDS/002_function/dssql.sas @@ -3,6 +3,8 @@ /* >>> dsSQL() function: <<< * * Internal function called by %SQL() macro. + * The function pass query code from the %SQL() + * macro to the %dsSQL_Inner() innternal macreo. * * Recommended for SAS 9.3 and higher. * Based on paper: diff --git a/SQLinDS/description.sas b/SQLinDS/description.sas index 722e782..c30b1c2 100644 --- a/SQLinDS/description.sas +++ b/SQLinDS/description.sas @@ -23,14 +23,23 @@ the macro-function-sandwich concept introduced in: "Use the Full Power of SAS in Your Function-Style Macros" the article by Mike Rhoads, Westat, Rockville, MD -Copy of the article can be found at: +Copy of the article is available at: https://support.sas.com/resources/papers/proceedings12/004-2012.pdf -SQLinDS package provides following components: - 1) %dsSQL_inner() macro - 2) dsSQL() function - 3) %SQL() macro +Package provides ability to "execute" SQL queries inside a datastep, e.g. -Library DSSQL is created in a subdirectory of the WORK library. + data class; + set %SQL(select * from sashelp.class); + run; + +SQLinDS package contains the following components: + + 1) %SQL() macro - the main package macro available for the User + + 2) dsSQL() function (internal) + 3) %dsSQL_inner() macro (internal) + 4) Library DSSQL (created in a subdirectory of the WORK library) + +See help for the %SQL() macro to find more examples. DESCRIPTION END: diff --git a/sqlinds.zip b/sqlinds.zip index db19518..b7f5631 100644 Binary files a/sqlinds.zip and b/sqlinds.zip differ