BookmarkSubscribeRSS Feed
diwashsapkota
Calcite | Level 5
Yeah, I checked the proc contents to check the size of variables but that
that also didn't work. This warning has been ever present in my code even
though I have been using the largest length value for the input variables.
6 REPLIES 6
LinusH
Tourmaline | Level 20

Please share you log with the code, and proc contents.

Data never sleeps
diwashsapkota
Calcite | Level 5
I am getting the following warnings in my code every time I specify the length of the variables:
WARNING: Multiple lengths were specified for the variable trt1 by input data set(s). This can cause truncation of data.
The code that is giving me the error is:
data oneae;
set dummy1 ae4(rename=(placebo=trt1 Xanomeline_High_Dose=trt2
Xanomeline_Low_Dose=trt3));
ord=1;
aeterm='Subject with at least one AE';
tot1="&bign1";
tot2="&bign2";
tot3="&bign3";
run;
LinusH
Tourmaline | Level 20

I think is kind of self explanatory.

Do a PROC CONTENTS on both input datasets and compare your variable definitions.

If you have deviations, you could specify a LENGTH statement prior to SET and use the largest length value for your input variable(s).

Data never sleeps
Patrick
Opal | Level 21

At least in my SAS9.4M7 environment under Windows you get this warning only if the variable in the first table got a shorter length defined than in the second table. 

SAS will use the first occurrence of a source variable to create the pdv and though if this first occurrence is the shorter length then string truncation is possible and though the Warning is correct and should remain. 

 

One way to avoid such a truncation issue is to define the variable length explicitly before the set statements.

ata have1;
  length var $1;
  var='A';
run;
data have2;
  length var $2;
  var='BB';
run;

/* creates warning because test1 got the variable with a shorter length */
data test1;
  set have1 have2;
run;

/* var with greater length defined before the set statement: no warning */
data test2;
  length var $2;
  set have1 have2;
run;

/* source table with var that has greater length first in set statement: no warning */
data test3;
  set have2 have1;
run;


/* and here if you don't know the max length in advance */
proc sql;
  create table layout as
    select * from have1(obs=0)
    union corr all
    select * from have2(obs=0)
    ;
quit;

data test4;
  set layout have1 have2;
run;

 

Astounding
PROC Star

Based on this program, what you need to compare is:

 

The length of TRT1 in DUMMY1

vs.

The length of PLACEBO in AE4

 

If you try to control the length using a LENGTH statement, that statement must come before the SET statement.

Ksharp
Super User
As long as you make sure the length of this variable is long enough ,and would not get any problem, you could try this option to suppress the warning info.

option varlenchk=nowarn;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 6 replies
  • 557 views
  • 0 likes
  • 5 in conversation