StepTimeScope is a lightweight SAS package for reviewing relative processing time across DATA and PROC steps. It records elapsed-time information with PROC SCAPROC, produces a concise step-level table, and can create a chart to surface potential hotspots. It is designed for quick performance checks and comparisons.
%timer_start();
data work.class_bmi;
set sashelp.class;
bmi = weight / (height ** 2) * 703;
run;
proc sort data=work.class_bmi out=work.class_bmi_sort;
by age sex;
run;
proc means data=work.class_bmi_sort n mean min max;
var age height weight bmi;
run;
%timer_end();
%timer_start();
/* Step 1: Create a large synthetic transaction data set */
data work.transactions;
length region $3 product $5;
format transaction_date yymmdd10. amount comma14.2;
call streaminit(20261102);
do transaction_id = 1 to 2000000;
customer_id = rand('integer', 1, 300000);
region = cats('R', put(rand('integer', 1, 20), z2.));
product = cats('P', put(rand('integer', 1, 500), z4.));
transaction_date = '01JAN2023'd + rand('integer', 0, 1095);
quantity = rand('integer', 1, 20);
amount = round(quantity * rand('uniform') * 20000, .01);
output;
end;
run;
/* Step 2: Sort the large transaction data set */
proc sort data=work.transactions out=work.transactions_sorted;
by region product transaction_date customer_id;
run;
/* Step 3: Summarize transactions by region and product */
proc summary data=work.transactions_sorted nway;
class region product;
var amount quantity;
output out=work.product_summary(drop=_type_ _freq_)
n(amount)=transaction_count
sum(amount)=total_amount
mean(amount)=mean_amount
sum(quantity)=total_quantity;
run;
/* Step 4: Join summary values back to transaction-level data */
proc sql;
create table work.transactions_enriched as
select
a.*,
b.transaction_count,
b.total_amount,
b.mean_amount,
b.total_quantity
from work.transactions_sorted as a
left join work.product_summary as b
on a.region = b.region
and a.product = b.product;
quit;
/* Step 5: Assign each transaction to an amount decile */
proc rank data=work.transactions_enriched
out=work.transactions_ranked
groups=10;
var amount;
ranks amount_decile;
run;
/* Step 6: Create a final summary by region and amount decile */
proc sql;
create table work.performance_result as
select
region,
amount_decile,
count(*) as record_count,
sum(amount) as total_amount format=comma18.2,
mean(amount) as mean_amount format=comma14.2,
mean(quantity) as mean_quantity format=8.2
from work.transactions_ranked
group by region, amount_decile
order by region, amount_decile;
quit;
%timer_end(plot=Y);
Starts step-level elapsed-time collection for relative performance review of subsequent DATA and PROC steps.
Uses PROC SCAPROC to record processing metadata in a temporary file under the WORK directory. FULLSTIMER is enabled for supplemental information in the SAS log.
%timer_start();
data work.class_bmi;
set sashelp.class;
bmi = weight / (height ** 2) * 703;
run;
proc sort data=work.class_bmi out=work.class_bmi_sort;
by age sex;
run;
proc means data=work.class_bmi_sort n mean min max;
var age height weight bmi;
run;
%timer_end();See also: %timer_end()
Stops elapsed-time collection, creates a step-level summary table, and optionally produces a bar chart.
plot=
Y : Creates a processing-time bar chart (default).
N : Creates the summary table only.
WORK.SCAPROC_ELAPSED Contains step number, process type, elapsed time in milliseconds, and elapsed time in seconds.
The output data set is created with GENMAX=100.
When %timer_start() and %timer_end() are run repeatedly in the same SAS session, up to 100 previous results are retained as generation data sets.
Intended for relative performance checks and hotspot identification. It is not a real-time monitoring or precise benchmarking tool.
%timer_start();
data work.class_bmi;
set sashelp.class;
bmi = weight / (height ** 2) * 703;
run;
proc sort data=work.class_bmi out=work.class_bmi_sort;
by age sex;
run;
proc means data=work.class_bmi_sort n mean min max;
var age height weight bmi;
run;
%timer_end(); Requires: %timer_start() must be run before this macro.
- 0.1.0(02November2026): Initial version.
The package is built on top of SAS Packages Framework(SPF) developed by Bartosz Jablonski.
For more information about the framework, see SAS Packages Framework.
You can also find more SAS Packages (SASPacs) in the SAS Packages Archive(SASPAC).
First, create a directory for your packages and assign a packages fileref to it.
filename packages "\path\to\your\packages";Secondly, enable the SAS Packages Framework. (If you don't have SAS Packages Framework installed, follow the instruction in SPF documentation to install SAS Packages Framework.)
%include packages(SPFinit.sas)Install SAS package you want to use with the SPF's %installPackage() macro.
-
For packages located in SAS Packages Archive(SASPAC) run:
%installPackage(packageName)
-
For packages located in PharmaForest run:
%installPackage(packageName, mirror=PharmaForest)
-
For packages located at some network location run:
%installPackage(packageName, sourcePath=https://some/internet/location/for/packages)
(e.g.
%installPackage(ABC, sourcePath=https://github.com/SomeRepo/ABC/raw/main/))
Load SAS package you want to use with the SPF's %loadPackage() macro.
%loadPackage(packageName)