From c090c8d53b5c7ee02803eeeb84dc4a188874b6a6 Mon Sep 17 00:00:00 2001 From: Allan Bowe <> Date: Fri, 25 Dec 2020 10:18:02 +0000 Subject: [PATCH] feat: simple macro to test the write speed for a library (very very basic) --- base/mp_testwritespeedlibrary.sas | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 base/mp_testwritespeedlibrary.sas diff --git a/base/mp_testwritespeedlibrary.sas b/base/mp_testwritespeedlibrary.sas new file mode 100644 index 0000000..b2f0742 --- /dev/null +++ b/base/mp_testwritespeedlibrary.sas @@ -0,0 +1,59 @@ +/** + @file mp_testwritespeedlibrary.sas + @brief Tests the write speed of a new table in a SAS library + @details Will create a new table of a certain size in an + existing SAS library. The table will have one column, + and will be subsequently deleted. + + %mp_testwritespeedlibrary( + lib=work + ,size=0.5 + ,outds=work.results + ) + + @param lib= (WORK) The library in which to create the table + @param size= (0.1) The size in GB of the table to create + @param outds= (WORK.RESULTS) The output dataset to be created. + +

SAS Macros

+ @li mf_getuniquename.sas + @li mf_existds.sas + + @version 9.4 + @author Allan Bowe + +**/ + +%macro mp_testwritespeedlibrary(lib=WORK + ,outds=work.results + ,size=0.1 +)/*/STORE SOURCE*/; +%local ds start; + +/* find an unused, unique name for the new table */ +%let ds=%mf_getuniquename(); +%do %until(%mf_existds(&lib..&ds)=0); + %let ds=%mf_getuniquename(); +%end; + +%let start=%sysfunc(datetime()); + +data &lib..&ds(compress=no keep=x); + header=128*1024; + size=(1073741824/8 * &size) - header; + do x=1 to size; + output; + end; +run; + +proc sql; +drop table &lib..&ds; + +data &outds; + lib="&lib"; + start_dttm=put(&start,datetime19.); + end_dttm=put(datetime(),datetime19.); + duration_seconds=end_dttm-start_dttm; +run; + +%mend; \ No newline at end of file