wrapit5.pl -- Wrap SAS or SPSS Variable Input Statements to Multiple Columns


This Perl script reads a file containing a single column of SAS Input or SPSS Data List statements and changes them into a wrapped format with multiple fields per line--defaulting to five columns wide. Handy for making long, single-column SAS or SPSS input declarations more compact and readable in your code.

Usage

The command line is: perl wrapit5.pl filename >filename.out

This utility is part of my collection of text-processing tools.
Here is an example. Consider this input data:

Sample input (cards):

   V1 1-4         
   V2 5-8         
   V3 9-9         
   V4 10-13 (A)   
   V5 14-14 
   V6 15-16       
   V7 17-17       
   V8 18-19       
   V9 20-21      
   V10 22-23 
   V11 24-25      
   V12 26-26      
   V13 27-28      
   V14 29-33 (A)  
   V15 34-35 
   V16 36-37      
   V17 38-39      
   V18 40-41      
   V19 42-46 (A)  
   V20 47-47

The command perl wrapit5.pl cards > cards.wrap produces this:

 Sample output (cards.wrap):

   V1 1-4         V2 5-8         V3 9-9         V4 10-13 (A)   V5 14-14
   V6 15-16       V7 17-17       V8 18-19       V9 20-21       V10 22-23
   V11 24-25      V12 26-26      V13 27-28      V14 29-33 (A)  V15 34-35
   V16 36-37      V17 38-39      V18 40-41      V19 42-46 (A)  V20 47-47

Back to Kent's Perl Page Last modified: Sat Sep 6 16:57:04 EDT 2025