Date: Wed, 24 Sep 2008 16:35:58 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Subject: Re: Compare variables in two data sets
On Wed, 24 Sep 2008 11:25:53 -0500, ./ ADD NAME=Data _null_,
<iebupdte@GMAIL.COM> wrote:
>The "others" will show you how to do this using dictionary.columns,
>comparing the variable names with a merge(join) to return the names
>that don't come from both places.
>
>However, you may find this method using PROC COMPARE amusing.
>
>data class1(drop=weight) class2(drop=height);
> set sashelp.class;
> run;
>
>proc compare base=class1(obs=0) compare=class2(obs=0) listvar brief;
> run;
>
>
>On 9/24/08, Peter Flom <peterflomconsulting@mindspring.com> wrote:
>> Hi again all
>>
>> I have two data sets, each with many variables .... most of the variables
are in both data sets.
>>
>> Is there a way to make a list of variables that are in only ONE of the
data sets?
>>
>> thanks
>>
>> Peter
>>
>> Peter L. Flom, PhD
>> Statistical Consultant
>> www DOT peterflom DOT com
>>
Change "obs=0" to "obs=1" to get rid of the WARNING in the log (unless of
course one of the data sets is in fact empty).
The SQL set operators provide an alternative:
select name
from dictionary.columns
where libname='WORK' and memname='CLASS1'
except
select name
from dictionary.columns
where libname='WORK' and memname='CLASS2'
;
Switch the MEMNAME restrictions to get the mirror image. UNION the results
to get the composite list.