The `%mp_testjob` macro is designed to test performance or maintain an active session. It initializes a temporary library in WORK, then enters a loop conditioned by the desired execution duration (`duration` parameter). In each iteration, it generates a large dataset (1 million observations) with random values, aggregates it via PROC SUMMARY, enriches it via PROC SQL, and sorts it via PROC SORT. It includes a 5-second pause between cycles. Finally, it cleans up datasets and frees the library.
Data Analysis
Type : CREATION_INTERNE
Data is algorithmically generated (`ranuni` function) within the macro. No external data dependency.
1 Code Block
Macro Variable
Explanation : Timer initialization and creation of a unique temporary workspace (folder and libref) to isolate test data.
Copied!
%let start_tm=%sysfunc(datetime());
%let duration=%sysevalf(&duration);
/* create a temporary library in WORK */
%let lib=%mf_getuniquelibref();
%let dir=%mf_getuniquename();
%mf_mkdir(%sysfunc(pathname(work))/&dir)
libname &lib "%sysfunc(pathname(work))/&dir";
1
%let start_tm=%sysfunc(datetime());
2
%let duration=%sysevalf(&duration);
3
4
/* create a temporary library in WORK */
5
%let lib=%mf_getuniquelibref();
6
%let dir=%mf_getuniquename();
7
%mf_mkdir(%sysfunc(pathname(work))/&dir)
8
LIBNAME &lib "%sysfunc(pathname(work))/&dir";
2 Code Block
DATA STEP Data
Explanation : Generation of a large dataset (1M rows) containing random numbers and a repeated character string, without compression to maximize I/O.
Copied!
data &lib..&ds1(compress=no );
do x=1 to 1000000;
randnum0=ranuni(0)*3;
randnum1=ranuni(0)*2;
bigchar=repeat('A',300);
output;
end;
run;
1
DATA &lib..&ds1(compress=no );
2
DO x=1 to 1000000;
3
randnum0=ranuni(0)*3;
4
randnum1=ranuni(0)*2;
5
bigchar=repeat('A',300);
6
OUTPUT;
7
END;
8
RUN;
3 Code Block
PROC SUMMARY Data
Explanation : Execution of a descriptive statistics procedure to consume CPU and memory on the generated data.
Copied!
proc summary ;
class randnum0 randnum1;
output out=&lib..&ds2;
run;quit;
1
PROC SUMMARY ;
2
class randnum0 randnum1;
3
OUTPUT out=&lib..&ds2;
4
RUN;QUIT;
4 Code Block
PROC SQL Data
Explanation : Use of SQL to create a new sorted table with an additional calculated column, testing the SQL engine's performance.
Copied!
proc sql;
create table &lib..&ds3 as
select *, ranuni(0)*10 as randnum2
from &lib..&ds1
order by randnum1;
quit;
1
PROC SQL;
2
create TABLE &lib..&ds3 as
3
select *, ranuni(0)*10 as randnum2
4
from &lib..&ds1
5
order BY randnum1;
6
QUIT;
5 Code Block
PROC SORT
Explanation : Sorting the resulting dataset to test sorting performance (I/O intensive).
Copied!
proc sort data=&lib..&ds3;
by descending x;
run;
1
PROC SORTDATA=&lib..&ds3;
2
BY descending x;
3
RUN;
6 Code Block
DATA STEP
Explanation : 5-second pause in execution to simulate waiting time or reduce continuous system pressure.
Copied!
data _null_;
call sleep(5,1);
run;
1
DATA _null_;
2
call sleep(5,1);
3
RUN;
7 Code Block
PROC DATASETS
Explanation : Final cleanup: deletion of all tables created in the temporary library and release of the library assignment.
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.
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.