Camille
Camille

Reputation: 233

How do I output comparison for certain columns only using SAS?

I am trying to compare two Excel worksheets (two different workbooks). 1) I have imported both files - fine 2) I have written some code in SAS and it brings out the correct output

Now, I would like for it to only output comparison for those column headings which have the word 'biggest' in it.

Here is the code:

PROC COMPARE
BASE=WORK.DATA_201605 
COMPARE=WORK.DATA_201606 
out=dif
outbase
outcomp
outnoequal
listall
OUTDIF 
METHOD=PERCENT 
CRITERION=10.00 maxprint=(1000);
ID Mainid;
run;

Upvotes: 0

Views: 285

Answers (2)

Chris J
Chris J

Reputation: 7769

Use the dictionary.columns SQL view to determine the columns :

proc sql ;
  select distinct name into :VARLIST separated by ' ' 
  from dictionary.columns
  where libname = 'WORK'
    and memname = 'DIF'
    and upcase(name) like '%BIGGEST%' ;
quit ;

proc print data=dif ;
  var &VARLIST ;
run ;

Upvotes: 1

Reeza
Reeza

Reputation: 21264

Have you tried the VAR statement? Along with colon to shortcut your prefix. Something like:

Var biggest: ;

Upvotes: 0

Related Questions