Techie Tip: Test Data Set Creation Macro
By Bryan K. Beverly, BAE Systems Information Technology
This program allows an end user to create temporary SAS test data
sets, with the option of specifying the number records and the number
of variables per record.
The end user also has the options of choosing:
(1) data set compression and space
reuse
(2) output page specifications
(3) macro debugging.
options nosymbolgen; /*DEFAULT
MACRO DEBUGGING STATUS*/
%macro test_data(rec=, /*
specify the number of records */
var=, /*
specify the number of variables per record */
compress=, /*
compress the test data set? */
reuse=, /*
reuse free space in the test data set? */
linesize=, /*
specify linesize of output (if any) */
pagesize=, /*
specify pagesize of output (if any) */
mcrodbug= /*
enable SYMBOLGEN > Y or N */
);
/* INITIALIZE ENVIRONMENT PRIOR TO EXECUTION
*/
options fullstimer compress=&compress reuse=&reuse ls=&linesize
ps=&pagesize;
%if %upcase(&mcrodbug)=Y %then %do;
options symbolgen; /*Turn
on resolution of macros*/
%end;
%else %do;
options nosymbolgen; /*Turn
off resolution of macros*/
%end;
proc datasets kill nolist; /*Delete
temporary SAS data sets*/
run;
quit;
/* CREATE TEST SAS DATASET */
data testdata1 (drop=n recs);
do recs=1 to &rec; /*Create
records from 1 to N*/
array vars{*} var1-var&var; /*Create
variables on each record from 1 to N*/
do n=1 to &var;
vars{n}=sqrt(recs/&var); /*Assign
a value to each variable on every record*/
end;
output;
end;
run;
%mend test_data;
%test_data(rec=1000,var=1000,compress=yes,
reuse=yes, linesize=132, pagesize=75, mcrodbug=y);
|