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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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