- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
581 options varlenchk=nowarn;
582 proc append base=varImphsp data=work.bs_varImphsp force nowarn;
583 run;
WARNING: Variable variable has different lengths on BASE and DATA files (BASE 32 DATA 3).
How to remove the warning?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So use a DATA step to make the structures consistent.
data base;
length name $20 ;
stop;
run;
data new;
input name :$10. ;
cards;
Joe
Sam
;
data new2;
set base(obs=0) new;
run;
proc append base=base data=new2 ;
run;
The data step could be a view.
The data step will still generate a warning if the new dataset defines the variables as LONGER than the target dataset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make the data structures match.
Why are they different now? How did you create the original (BASE) dataset? How did you create the new (DATA) dataset?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The code is a section of a macro loop. The BASE is the final result dataset, the DATA is one ODS output of proc hpsplit of each iteration.
Now, the only solution for me is adding a data step or SQL to modify the variable length of the DATA dataset.
I want to know if there is a more simple and direct solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That is one of the problems with using ODS OUTPUT to generate datasets. The structure is not consistent as it depends on the values that the procedure wants to DISPLAY for this analysis.
If you switch to using actual OUT= datasets (if available in the PROC(s) you are using) then the structure will be more consistent.
You will want to define a structure and use that. Probably best to define it before the first iteration of the loop.
That might be enough. Just make sure to define the character variables long enough for all possible values.
data base ;
length .....
stop;
run;
%do .....
ods output mystat = next ;
...
proc append base=base data=next force;
run;
%end;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tom,
This is exactly my current solution. The proc append would issue the WARNING.
data base;
length .....;
set first_data;
run;
.......
/*except the first data*/
proc append base=base data=data force;
run;
The purpose of using the proc append is about efficiency. But now, I think that there is unnecessary to think about the efficiency since the ODS output datasets are small. So, instead of proc append, I will use the data step.
data base_set;
set base_set data_set;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Add the NOWARN option to suppress the warnings.
proc append base=base data=next force nowarn ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So use a DATA step to make the structures consistent.
data base;
length name $20 ;
stop;
run;
data new;
input name :$10. ;
cards;
Joe
Sam
;
data new2;
set base(obs=0) new;
run;
proc append base=base data=new2 ;
run;
The data step could be a view.
The data step will still generate a warning if the new dataset defines the variables as LONGER than the target dataset.