Dear All:
I have around 50 tables that I hope to combine into one using:
data data_combo;
set data1-data50;
run;
These tables contain common variable names. But I got the following error message:
Multiple lengths were specified for the variable VARIABLEXXX by input data set(s). This may cause truncation of data.
How could I avoid such problem by just specify in the data_combo, the length of the variable is set as the largest of the all the tables that are going to be combined into DATA_COMBO? Right now, I have to do a PROC CONTENTS to see the variable length for all of the table and then manually specify the maximum length
Suppose that the data are stored in d:\sasdata\ and the libname for it is mydata. How would I accommodate the code?
I tried to modify the code into:
where libname eq 'mydata' and upcase(memname) eq: 'DATA'; |
But it doesn't seem to work...
Hi,
change
where libname eq 'mydata' and upcase(memname) eq: 'DATA';
to
where libname eq 'MYDATA' /* has to be upcase */ and upcase(memname) eq: 'DATA';
Message was edited by: Linlin
Alternatively if go for Proc SQL route:
proc sql;
select distinct cats(upcase(name),'$', max(LENGTH)) into :len separated by ' ' from dictionary.columns
where LIBNAME='WORK'
AND SUBSTR(MEMNAME,1,4)='DATA'
AND type='char'
group by upcase(name);
QUIT;
data want;
length &len;
set data1-data4;
run;
Haikuo
Update: this only works for Char vars. While I have never seen a different length for Num other than 8 in my real work.
Hi, Hai:
I modify the libname = 'mydata', but the program report:
Syntax error, expecting one of the following: a name, ;, DEFAULT, _ALL_,
_CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored
libname = 'MYDATA', needs CAPS.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.