data scoredata1;
set scoredata0;
length phone_update $10; /*without this the length will be 200*/
phone_update = TRANWRD(phone,'000','408');
run;
when I use TRANWRD to replace '000' of 'phone' by '408', I find that a length definition is needed for the new variable of 'phone_update". Otherwise, the length of phone_update will be 200. Will all new variables defined by a function require to define its length?
I note that this is different for a trim and CATX functions:
data scoredata2;
set scoredata1;
/*the concatenation operator and Trim function*/
student_name1 = trim(last_name) || ', ' || trim(first_name);
/*the CATX function enables you to concatenate character strings,
remove leading and trailing blanks, and insert separators*/
length student_name2 $25;
student_name2 = catx(', ',last_name,first_name);
run;
the student_name1 by trim is defined by the input variables, last_name and first-name, while the length of student_name2 is 200 if removing the length function.
I am a bit confused when a length definition is needed. will a length of 200 slow down the operation and take too much memory space? The length of variables can be easily checked through
proc contents data=xxx
run;