SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
siddhu1
Quartz | Level 8

Hi Team,

While appending the datasets using proc append with the Force option, one variable is of different length in the source and target.
I am getting the warning message that of varying lengths and the values has been truncated for this variable.

WARNING: Variable Cur_City has different lengths on BASE and DATA files
(BASE 22 DATA 50).
NOTE: FORCE is specified, so dropping/truncating will occur.

Also checked using the Proc Print, the values of curr_city has been truncated.

I can't use the options varlenchk=nowarn as it is unacceptable for the warnings to suppress in the Live environment.

Can anyone suggest the ideas on how to proceed further without the truncated values and warnings.


Thanking You,
Siddhu1

10 REPLIES 10
PaigeMiller
Diamond | Level 26

Change the length of the variable in the BASE data set to 50, before you run PROC APPEND.

--
Paige Miller
Ksharp
Super User

As Paige said , change the variable length in DATA file.

But make sure you would not lost any information in Cur_City .

 

data have;
set sashelp.class;
run;


proc sql;
alter table have 
modify name char(22);
quit;

 

PaigeMiller
Diamond | Level 26

@Ksharp wrote:

As Paige said , change the variable length in DATA file.


I said the opposite, change the length in the BASE data set.

--
Paige Miller
Ksharp
Super User
Yeah. You are right . the longer length is more safe .
siddhu1
Quartz | Level 8
I will change the variable length and try.
Thanks for the reply.

Siddhu1
AMSAS
SAS Super FREQ

Down side to this approach is APPEND doesn't process the base data, where as datastep will
So if you only need to append a few observations to a large base dataset then data step will be less efficient.


Kurt_Bremser
Super User

@AMSAS wrote:

Down side to this approach is APPEND doesn't process the base data, where as datastep will
So if you only need to append a few observations to a large base dataset then data step will be less efficient.



Yes, but if you need to adapt the base dataset to a new structure anyway (as in this case), the data step does both actions in one step.

Ksharp
Super User
Kurt,
I like your code.
But what if one variable is smaller in BASE, another variable is smaller in APPEND ?

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 10 replies
  • 2633 views
  • 3 likes
  • 5 in conversation