Explore using the SAS-maintained DICTIONARY table information called COLUMNS (or SAS view SASHELP.VCOLUMN) to get the SAS variable names and associated LENGTH information. You can use this information to generate and execute SAS code on-the-fly.
Scott Barry
SBBWorks, Inc.
Programming with the SQL Procedure
Accessing SAS System Information by Using DICTIONARY Tables
http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001385596.htm
Using Metadata and Project Data for Data-Driven Programming
Brian Varney, COMSYS IT Partners, Inc., Kalamazoo, Michigan
http://www2.sas.com/proceedings/sugi31/045-31.pdf