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

I am using the follwing proc compare. But I am seeing the difference  of Variable length in Result viewer, can we avoid with any option or statements. I tried this.

 

proc compare base=have comp=want listall ;
informat _all_;
format _all_;
attrib _all_
label=' ';
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
 length name $ 40;
 set sashelp.class;
run;


ods exclude CompareVariables;
proc compare base=sashelp.class comp=have listall ;
informat _all_;
format _all_;
attrib _all_
label=' ';
run;

View solution in original post

5 REPLIES 5
Ksharp
Super User
data have;
 length name $ 40;
 set sashelp.class;
run;


ods exclude CompareVariables;
proc compare base=sashelp.class comp=have listall ;
informat _all_;
format _all_;
attrib _all_
label=' ';
run;
Tom
Super User Tom
Super User

Why would you want that?

You could exclude that whole part of the output, but then you would miss other information that is printed there.

Example:

data have(drop=long) want(drop=name rename=(long=name));
  length long $20;
  set sashelp.class;
  long=name;
  output have;
  if _n_=1 then age=9;
  output want;
run;
ods trace on;
ods exclude CompareVariables ;
proc compare data=have compare=want;
run;
ods exclude none;
ods trace off;
StudentSASLearn
Obsidian | Level 7

I am comparing the table calculated values done by someone else, variable lengths are not important to compare. I was interested in actual values present in data. when I see so many variables with length differences, it kind of annoying ( I am aware sas presents it for a reason). In this case variable lengths are not important to compare.

StudentSASLearn
Obsidian | Level 7

Thank you Ksharp and Tom. Both given the same answers which worked for me. I don't know How I can accept  both as solutions. So I selected first one. Sorry Tom🙏

Tom
Super User Tom
Super User

You could also just check the SYSINFO macro variable that PROC COMPARE generates and ignore the bits that indicate the variable attribute differences you don't care about.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1jbbrf1tztya8n1tju77t35dej9.htm

 

Tom_0-1736429891580.png

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1761 views
  • 4 likes
  • 3 in conversation