SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 49583: Fixing multiple length problems when merging many data sets

DetailsCodeAboutRate It

Many times multiple data sets in a library need to be merged, but because they were created from different text files or different spread sheets, some variables will have different lengths in different data sets. This can cause truncation of data or a failure to match when merging.

This program will inspect each data set in a library, find all of the character variables and find the maximum length of that variable in any data set. A map is created that has each data set, the character variables in it, and what the length needs to be to avoid problems.

The program then writes a DATA step for each data set that adjusts the lengths of the character variables that the data set contains.

Because the program needs to create a data set, there are three pieces of information that the user needs to supply:

  • The library to examine and update
  • The library to create the temporary data set
  • The name of the temporary data set

When the program is complete, the temporary data set is deleted.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.