BookmarkSubscribeRSS Feed
indru1997
New User | Level 1

Hi all,

I have two datasets which have labels as below

indru1997_0-1769700663563.png

When I try to compare both these datasets, the label comparison section is not coming up as shown below,

indru1997_1-1769700780823.png

Does anyone know how to solve this?

4 REPLIES 4
sbxkoenk
SAS Super FREQ

Are you sure you have labels for the datasets compared?

 

For me it works:

sbxkoenk_0-1769702314662.png

 

What if you do a PROC CONTENTS?

In the very first output table (Results) ... do you see your label?

sbxkoenk_1-1769702398656.png

Ciao,

Koen

 

sbxkoenk
SAS Super FREQ

per the doc:

Note: The COMPARE procedure omits data set labels if the line size is too small for them.

 

I guess you have an enormous lot of trailing blanks in your label ! Please trim the label!

 

[EDIT] ... or augment the line size with the linesize option.

 

Cheers,

Koen

Kathryn_SAS
SAS Employee

You  can check the current Linesize and then increase it.

proc options option=linesize;
run;

options linesize=120;
Tom
Super User Tom
Super User

Check your LINESIZE setting.  

With LINESIZE set to 132 (normal line printer carriage length) it will display labels up to 72 bytes long.

 73         %put linesize=%sysfunc(getoption(ls));
 linesize=132
 74         data one(label='First') 
two(label="%substr(%sysfunc(repeat(Second,20)),1,72)");
 75           set sashelp.class;
 76         run;

Screenshot 2026-01-29 at 5.14.16 PM.png

NOTE: PROC COMPARE (or perhaps the actual way that labels are stored in the SAS dataset) treats trailing spaces differently than the rest of SAS treats them.   

 73         data test1(label='NoTrailing')
 74              test2(label='Trailing  ')
 75         ;
 76         x=1;
 77         run;
 
 NOTE: The data set WORK.TEST1 has 1 observations and 1 variables.
 NOTE: The data set WORK.TEST2 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         
 79         %let dsn=test1;
 80         %let dsid=%sysfunc(open(&dsn,i));
 81         %put &=dsn LABEL="%sysfunc(attrc(&dsid,label))";
 DSN=test1 LABEL="NoTrailing"
 82         %let dsn=test2;
 83         %let dsid=%sysfunc(open(&dsn,i));
 84         %put &=dsn LABEL="%sysfunc(attrc(&dsid,label))";
 DSN=test2 LABEL="Trailing  "
 85         %let dsid=%sysfunc(close(&dsid));

So if you are defining the labels using quoted strings make sure not to include the trailing spaces. 

 

If you are creating macro variables to generate the LABEL then take care not to add trailing spaces into the macro variable.

  • Always use the modern CALL SYMPUTX() method instead of the ancient CALL SYMPUT() method
  • In PROC SQL add the TRIMMED option to your INTO clause.
  • If adding the quotes into the value make sure to use TRIM() function before adding the quotes.  (quote(trim(label))
  • If writing the code to a file using PUT statement make sure to add the : modifier.  PUT LABEL :$quote. ;

 

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
  • 4 replies
  • 97 views
  • 0 likes
  • 4 in conversation