Production Ready Macros for SAS Application Developers
mp_getmaxvarlengths.sas File Reference

Scans a dataset to find the max length of the variable values. More...

Go to the source code of this file.

Detailed Description

This macro will scan a base dataset and produce an output dataset with two columns:

  • COL Name of the base dataset column
  • MAXLEN Maximum length of the data contained therein.

Character fields may be allocated very large widths (eg 32000) of which the maximum value is likely to be much narrower. This macro was designed to enable a HTML table to be appropriately sized however this could be used as part of a data audit to ensure we aren't over-sizing our tables in relation to the data therein.

Numeric fields are converted using the relevant format to determine the width. Usage:

%mp_getmaxvarlengths(sashelp.class,outds=work.myds);
Parameters
libdsTwo part dataset (or view) reference.
outds=The output dataset to create
Version
9.2
Author
Allan Bowe

Definition in file mp_getmaxvarlengths.sas.