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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

7 REPLIES 7
Tom
Super User Tom
Super User

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?

su35
Obsidian | Level 7
Thanks Tom.
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.
Tom
Super User Tom
Super User

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;
su35
Obsidian | Level 7

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;
Tom
Super User Tom
Super User

Add the NOWARN option to suppress the warnings.

 

proc append base=base data=next force nowarn ;

 

su35
Obsidian | Level 7
as the original post showed, the nowarn option doesn't work.
Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 8013 views
  • 0 likes
  • 2 in conversation