DATA Step, Macro, Functions and more

how to remove conflicting attributes warning from sas proc compare output?

Reply
Occasional Contributor
Posts: 14

how to remove conflicting attributes warning from sas proc compare output?

Hi Below is the excerpt from log which I am getting . please me to remove this warning.

 

WARNING: 4 variables have conflicting attributes in the two data sets.

 
    Listing of Common Variables with Differing Attributes

 Variable       Dataset      Type  Length  Format   Informat

 LBL_ID         WORK.LIBPRD  Char      80  $80.
                WORK.LIBNEW  Char      80  $80.
 LBL_NAME       WORK.LIBPRD  Char      80  $80.
                WORK.LIBNEW  Char      80  $80.
 DBETYBRCON_BK  WORK.LIBPRD  Num        8  BEST12.  BEST32.
                WORK.LIBNEW  Num        8
 LBL_COMMENT    WORK.LIBPRD  Char      80  $80.
                WORK.LIBNEW  Char      80  $80.

Super User
Super User
Posts: 9,227

Re: how to remove conflicting attributes warning from sas proc compare output?

You get rid of warnings/errors by fixing you code or data.   In this case fix your data to not have conflicting attributes and the warning will go away.  This one:

DBETYBRCON_BK  WORK.LIBPRD  Num        8  BEST12.  BEST32.

Clearly shows it has a format and informat on one dataset, and not on the other, that is a difference.  I suspect the others differ in label, but as that is not shown, I can't be sure.

 

The alternative is to remove the whole metadata compare part, its one of the options, which you can find a whole list and examples of in the SAS help docs:

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n0c1y14wyd3u7yn1dmfcp...

Occasional Contributor
Posts: 14

Re: how to remove conflicting attributes warning from sas proc compare output?

Hello
I have used
DBETYBRCON_BK = input(DBETYBRCON_BK1, ?? best32.);
in data step.
also I have a meta data in which I have defined
%LET DBETYBRCON_BK = DBETYBRCON_BK LENGTH=8. FORMAT=best12. ;
%LET iDBETYBRCON_BK = INFORMAT DBETYBRCON_BK best32. ;
%LET DBETYBRCON_BK1 = DBETYBRCON_BK1 FORMAT=$80.;
%LET iDBETYBRCON_BK1 = INFORMAT DBETYBRCON_BK1 $80.;

so I am unable to find why warning is coming
Super User
Super User
Posts: 9,227

Re: how to remove conflicting attributes warning from sas proc compare output?

Sorry, not sure what I can add.  Look at a proc contents of each of the dataset you will clearly see differences in the output.

 

"I have used
DBETYBRCON_BK = input(DBETYBRCON_BK1, ?? best32.);"

 

Firstly, avoid coding in upper case, no need to shout.  This tells me nothing, there is no attributation of the variable dbetybrcon_bk, it doesn't matter that you are reading in the data using an infomat,what is important is what the variable is created as what metadata is assigned.

 

"%LET DBETYBRCON_BK = DBETYBRCON_BK LENGTH=8. FORMAT=best12. ;
%LET iDBETYBRCON_BK = INFORMAT DBETYBRCON_BK best32. ;
%LET DBETYBRCON_BK1 = DBETYBRCON_BK1 FORMAT=$80.;
%LET iDBETYBRCON_BK1 = INFORMAT DBETYBRCON_BK1 $80.;"

Why?  Put data information in datasteps, macro is not a replacement for Base SAS!!! 

Even with that, you make no mention of label on any of those variables, for dbettbrcon_bk there is no informat attribute, for the i version, there is no length or format etc.

 

How to create a dataset:

data want;
  length dbetybrcon 8 ...;
  format dbetybrcon best12. ...;
  informat dbetybrcon best32. ...;
  label dbetybrcon "something" ...;
run;

Or you can blank all variables parts by:

data want;
  set want;
  format _all_;
  informat _all_;
run;

 

Occasional Contributor
Posts: 14

Re: how to remove conflicting attributes warning from sas proc compare output?

there is no label for DBETYBRCON_BK here. but for the other variable there are label. Yes I have used macro and inside macro i have called that meta variable . does attributes of the variable change when we assign some value to them ?

Super User
Super User
Posts: 9,227

Re: how to remove conflicting attributes warning from sas proc compare output?

Please show your exact code.  Variables are defined once, if they do not have a specific attribute then the default is used.  You can change these later on.  Do a proc datasets on each of the datasets, you will see what the differences are.

Again, I really recommend you don't put SAS code in macro variables, you are opening a whole host of problems for yourself.

Super User
Posts: 9,611

Re: how to remove conflicting attributes warning from sas proc compare output?


@Sukhi1 wrote:
there is no label for DBETYBRCON_BK here. but for the other variable there are label. Yes I have used macro and inside macro i have called that meta variable . does attributes of the variable change when we assign some value to them ?


Attributes of an existing variable do not change. Attributes of a new variable are set according to the values assigned to it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 14

Re: how to remove conflicting attributes warning from sas proc compare output?

Posted in reply to KurtBremser
DBETYBRCON_BK = input(DBETYBRCON_BK1, ?? best32.);"
So in this case new variable is DBETYBRCON_BK . right I wanted to have it attributes retained. after assignment.
Super User
Posts: 9,611

Re: how to remove conflicting attributes warning from sas proc compare output?


@Sukhi1 wrote:
DBETYBRCON_BK = input(DBETYBRCON_BK1, ?? best32.);"
So in this case new variable is DBETYBRCON_BK . right I wanted to have it attributes retained. after assignment.

Which is of course impossible because DBETYBRCON_BK1 is of type character and DBETYBRCON_BK is numeric.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 14

Re: how to remove conflicting attributes warning from sas proc compare output?

Posted in reply to KurtBremser
I have defined the format for the above field like this .
%LET DBETYBRCON_BK = DBETYBRCON_BK LENGTH=8. FORMAT=best12. ;
%LET iDBETYBRCON_BK = INFORMAT DBETYBRCON_BK best32. ;

now after assignment. that is after this line
DBETYBRCON_BK = input(DBETYBRCON_BK1, ?? best32.);"
it is getting something like this (proc compare)
DBETYBRCON_BK WORK.LIBPRD Num 8 BEST12. BEST32.
WORK.LIBNEW Num 8
Super User
Super User
Posts: 9,227

Re: how to remove conflicting attributes warning from sas proc compare output?

This,

"%LET DBETYBRCON_BK = DBETYBRCON_BK LENGTH=8. FORMAT=best12. ;"

Does not define anything.  It creates a macro variable containing the text "%LET DBETYBRCON_BK = DBETYBRCON_BK LENGTH=8. FORMAT=best12. ;".  

 

Also, in that string you do not specify an informat.  However with the code:

DBETYBRCON_BK = input(DBETYBRCON_BK1, ?? best32.);"

 

you are reading data in with an informat - best32.

 

As I mentioned above if you want to remove all of a certain property (we often remove all informats from a dataset);

data want;
  set have;
  informat _all_;
run;

Again, avoid shouting code, and using macro where it is not needed.

Occasional Contributor
Posts: 14

Re: how to remove conflicting attributes warning from sas proc compare output?

thanks I will remove all the format and informat for the time being.
Super User
Posts: 9,611

Re: how to remove conflicting attributes warning from sas proc compare output?

The %let does exactly NOTHING in itself, it just creates a macro variable for further use.

Unless you use it later in an attrib statement or as part of a SQL select, it's just waste of screen space.

 

And once again: a numeric variable CANNOT have the attributes of a character variable. PERIOD.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 14

Re: how to remove conflicting attributes warning from sas proc compare output?

Posted in reply to KurtBremser
thanks
Ask a Question
Discussion stats
  • 13 replies
  • 127 views
  • 0 likes
  • 3 in conversation