Data is dynamically generated by a `DATA STEP` within the macro (`do x=1 to size; output; end;`) to create a dataset of the specified size. No external data or data from SASHELP is used for the content of the tested dataset.
1 Code Block
Macro definition and initialization
Explanation : This block defines the `%mp_testwritespeedlibrary` macro with its parameters and their default values. It declares the local macro variables `ds` (for the temporary dataset name) and `start` (for the start timestamp). It uses a `%do %until` loop with the `%mf_getuniquename()` and `%mf_existds()` macros to generate a unique dataset name that does not yet exist in the specified library, ensuring no conflicts. Finally, it captures the operation's start time via `%sysfunc(datetime())`.
Copied!
%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());
1
%macro mp_testwritespeedlibrary(lib=WORK
2
,outds=work.results
3
,size=0.1
4
)/*/STORE SOURCE*/;
5
%local ds start;
6
7
/* find an unused, unique name for the new table */
8
%let ds=%mf_getuniquename();
9
%DO %until(%mf_existds(&lib..&ds)=0);
10
%let ds=%mf_getuniquename();
11
%END;
12
13
%let start=%sysfunc(datetime());
2 Code Block
DATA STEP Data
Explanation : This `DATA STEP` is the core of the performance measurement. It creates a dataset named `&lib..&ds` (the previously generated unique name) without compression (`compress=no`) and retaining only column `x` (`keep=x`). The `size` variable is calculated to determine the number of observations needed to reach the target size specified by the macro's `size` parameter (converted from GB to bytes and adjusted for a 'header'). The loop `do x=1 to size; output; end;` generates observations, thus simulating a significant write load.
Copied!
data &lib..&ds(compress=no keep=x);
header=128*1024;
size=(1073741824/8 * &size) - header;
do x=1 to size;
output;
end;
run;
1
DATA &lib..&ds(compress=no keep=x);
2
header=128*1024;
3
size=(1073741824/8 * &size) - header;
4
DO x=1 to size;
5
OUTPUT;
6
END;
7
RUN;
3 Code Block
PROC SQL
Explanation : This `PROC SQL` block executes a `DROP TABLE` statement to delete the temporary dataset `&lib..&ds` created previously. This is an essential cleanup step to prevent library clutter and ensure that tests are reproducible without residues from previous operations.
Copied!
proc sql;
drop table &lib..&ds;
run;
1
PROC SQL;
2
drop TABLE &lib..&ds;
3
RUN;
4 Code Block
DATA STEP Data
Explanation : This `DATA STEP` creates the final `&outds` dataset, which contains the performance test results. It records the library name (`lib`), the start time (`start_dttm`), and the end time (`end_dttm`) of the write operation (formatted as `datetime19.`). The `duration_seconds` is calculated by subtracting the start time from the end time, providing a direct measure of write speed.
Copied!
data &outds;
lib="&lib";
start_dttm=put(&start,datetime19.);
end_dttm=put(datetime(),datetime19.);
duration_seconds=end_dttm-start_dttm;
run;
1
DATA &outds;
2
lib="&lib";
3
start_dttm=put(&start,datetime19.);
4
end_dttm=put(datetime(),datetime19.);
5
duration_seconds=end_dttm-start_dttm;
6
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright (c) 2001-2006 Rodney Sparapani (from `_version.sas`), licensed under GNU General Public License. The macro's HELP block also references 'Copyright 2010-2023 HMS Analytical Software GmbH'.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.