- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Change the length of the variable in the BASE data set to 50, before you run PROC APPEND.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply.
Siddhu1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Or use a data step:
data new_base;
if 0 then set append; /* gets length from new dataset, but does nothing else */
set
base
append
;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I like your code.
But what if one variable is smaller in BASE, another variable is smaller in APPEND ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Then we need some coding that reads the max length from dictionary.columns and builds a LENGTH statement to use in place of the IF 0 THEN SET.