SPRING 2009
TECHIE TIPS
User Profile: Herman Lo
Read.
Education Profile: Nick Daudin
Read.
Have you changed companies? Do you want to modify your contact preferences? Don’t forget to update your SAS profile!

What's better than Starbucks coffee? FREE Starbucks coffee!

Submit your SAS techie tip to publish in future issues of insights and WIN a $10 gift card from Starbucks.
For details on all of SAS' products and solutions, click here.
The SAScom blog: http://blogs.sas.com/sascom/
SAS Canada
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);


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. Other brand and product names are trademarks of their respective companies. Copyright © 2009, SAS Institute Inc. All rights reserved.