Changing the length of a Character Variable
***************************************************************************************
Hello SAS Communities,
I recently used proc import to import data from a .xls file. One of the variables within the data set is a character variable and the desired length is 11 variables long, however, after importing the data into my program the length of this variable is now 12.
Here are the SAS Table Properties that show the variable length for the variable SSN and the proc import statement that I used:
PROC IMPORT
DATAFILE = "&CourseRoot/Study/Data/Source/DATA.xls"
OUT = WORK.DATA
DBMS = XLS
REPLACE ;
SHEET = "Sheet1";
RUN;
Is there any way to change the variable length for SSN from 12 to 11?
Thank you,
De'Janae' Guillory-Williams
You can change length of a variable, but you take a risk of assigning a too short and value might be truncated. The code is:
data want;
length SSN <new length>;
set have;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.