BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aayo
Obsidian | Level 7

Hello,

I am trying to combine imported datasets using macro but i get warning below

WARNING: Multiple lengths were specified for the variable A by input data set(s). This can cause
truncation of data.

 

Note that var A has different length format automatically assigned during the import procedure.

below is my code.

%macro combine;
data c;
set
%do i = 1 %to 2;
&library..&&file&i
%end;
;
run;
%mend;
%combine;

1 ACCEPTED SOLUTION

Accepted Solutions
ghosh
Barite | Level 11

Explicitly define the lengths of the offending variable(s) to their predetermined maximum value (eg. 60 chars)

%macro combine;
data c;
length problemvar $60;
set
%do i = 1 %to 2;
&library..&&file&i
%end;
;
run;
%mend;
%combine;

View solution in original post

4 REPLIES 4
ghosh
Barite | Level 11

Explicitly define the lengths of the offending variable(s) to their predetermined maximum value (eg. 60 chars)

%macro combine;
data c;
length problemvar $60;
set
%do i = 1 %to 2;
&library..&&file&i
%end;
;
run;
%mend;
%combine;
aayo
Obsidian | Level 7

This works fine. Thanks much.

Kurt_Bremser
Super User

Do not fix this here, prevent it when the data is imported in the first place. Do not use proc import, use a custom data step to read data, where you control all variable attributes.

See Maxims 31 and 22. Avoid Excel Files, convert to CSV first.

aayo
Obsidian | Level 7

Hi Kurt,

This is noted.

I have changed my import to data step and made use of csv file.

Thanks.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2002 views
  • 0 likes
  • 3 in conversation