diff --git a/all.sas b/all.sas index bbbd3c5..0b9befd 100644 --- a/all.sas +++ b/all.sas @@ -4612,7 +4612,7 @@ data &outds(keep=name type length varnum format label ddtype); else if formatd=0 then format=cats(format2,formatl,'.'); else format=cats(format2,formatl,'.',formatd); type='N'; - if format=:'DATETIME' then ddtype='DATETIME'; + if format=:'DATETIME' or format=:'E8601DT' then ddtype='DATETIME'; else if format=:'DATE' or format=:'DDMMYY' or format=:'MMDDYY' or format=:'YYMMDD' or format=:'E8601DA' or format=:'B8601DA' or format=:'MONYY' @@ -6325,6 +6325,59 @@ run; filename &tempref clear; %mend mp_include;/** + @file + @brief Initialise session with useful settings and variables + @details Implements a set of recommended options for general SAS use. This + macro is NOT used elsewhere within the core library (other than in tests), + but it is used by the SASjs team when building web services for + SAS-Powered applications elsewhere. + + If you have a good idea for an option, setting, or useful global variable - + feel free to [raise an issue](https://github.com/sasjs/core/issues/new)! + + All global variables are prefixed with "SASJS_" (unless modfied with the + prefix parameter). + + @param [in] prefix= (SASJS) The prefix to apply to the global macro variables + + + @version 9.2 + @author Allan Bowe + +**/ + +%macro mp_init(prefix= +)/*/STORE SOURCE*/; + + %global + &prefix._INIT_NUM /* initialisation time as numeric */ + &prefix._INIT_DTTM /* initialisation time in E8601DT26.6 format */ + ; + %if %eval(&&&prefix._INIT_NUM>0) %then %return; /* only run once */ + + data _null_; + dttm=datetime(); + call symputx("&prefix._init_num",dttm); + call symputx("&prefix._init_dttm",put(dttm,E8601DT26.6)); + run; + + options + autocorrect /* disallow mis-spelled procedure names */ + compress=CHAR /* default is none so ensure we have something! */ + datastmtchk=ALLKEYWORDS /* protection from overwriting input datasets */ + errorcheck=STRICT /* catch errors in libname/filename statements */ + fmterr /* ensure error when a format cannot be found */ + mergenoby=ERROR /* + missing=. /* some sites change this which causes hard to detect errors */ + noquotelenmax /* avoid warnings for long strings */ + noreplace /* avoid overwriting permanent datasets */ + ps=max /* reduce log size slightly */ + validmemname=COMPATIBLE /* avoid special characters etc in table names */ + validvarname=V7 /* avoid special characters etc in variable names */ + varlenchk=ERROR /* fail hard if truncation (data loss) can result */ + ; + +%mend mp_init;/** @file mp_jsonout.sas @brief Writes JSON in SASjs format to a fileref @details PROC JSON is faster but will produce errs like the ones below if @@ -7062,6 +7115,50 @@ lock &libds clear; ) %mend mp_lockfilecheck;/** + @file + @brief Create sample data based on the structure of an empty table + @details Many SAS projects involve sensitive datasets. One way to _ensure_ + the data is anonymised, is never to receive it in the first place! Often + consultants are provided with empty tables, and expected to create complex + ETL flows. + + This macro can help by taking an empty table, and populating it with data + according to the variable types and formats. + + The primary key is respected, as well as any NOT NULL constraints. + + Usage: + + proc sql; + create table work.example( + TX_FROM float format=datetime19., + DD_TYPE char(16), + DD_SOURCE char(2048), + DD_SHORTDESC char(256), + constraint pk primary key(tx_from, dd_type,dd_source), + constraint nnn not null(DD_SHORTDESC) + ); + %mp_makedata(work.example) + + @param [in] libds The empty table in which to create data + @param [out] obs= (500) The number of records to create. + +