DATA Step, Macro, Functions and more

Merging man data sets - Doubts

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 103
Accepted Solution

Merging man data sets - Doubts

Good morning and happy hollydays:

 

well i have to go back into my research cause i noticed my self mistakes in my original data sets, due merging issues:

 

i have tried this:

 

data merged_data;
merge a2005 a2006 a2007a a2007b a2008 a2009 a2010a a2010b a2010c a2010c1 a2010c2 a2010c3 a2010c4 a2010c5 a2010c6 a2010c7 a2010c8 a2010c9 a2012a1 a2012a2 a2012a3 a2012a4 a2012a5 a2012a6 a2012a7 a2013a1 a2013a2 a2013a12 a2013a3 a2013a4 a2013a5 a2013a6 a2013a7 a2013a8 a2013a9 a2013a10 a2014 a2015;
by animal;
run;

 

but it stills get duplicating many data, this because exhaustively searched the duplicate in the excel and i didnt find this.

 

each data contains in one column called Animal, and the other(s) measurements.

 

Thank you very much for your help

 

 


Accepted Solutions
Solution
‎12-28-2015 06:42 AM
Super User
Posts: 17,821

Re: Merging man data sets - Doubts

To find duplicates across the files/years you can append them keeping only the key variables and the data source. 

 

 

data stacked;
set a2005-a2015 indsname=datasource; *may need to explicitly list records or you can find some shortcuts using colon;
source=datasource;
keep animal source;
run;

proc sort data=stacked;
by animal source;
run;

*You expect 1 per file, but are getting multiples so you can see which years have multiples;
data dups;
set stacked;
if not (first.source and last.source) then output;
run;

View solution in original post


All Replies
Solution
‎12-28-2015 06:42 AM
Super User
Posts: 17,821

Re: Merging man data sets - Doubts

To find duplicates across the files/years you can append them keeping only the key variables and the data source. 

 

 

data stacked;
set a2005-a2015 indsname=datasource; *may need to explicitly list records or you can find some shortcuts using colon;
source=datasource;
keep animal source;
run;

proc sort data=stacked;
by animal source;
run;

*You expect 1 per file, but are getting multiples so you can see which years have multiples;
data dups;
set stacked;
if not (first.source and last.source) then output;
run;
Super User
Posts: 9,681

Re: Merging man data sets - Doubts

proc sort data=sashelp.class out=duplicate nounikeys;
by age;
run;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 260 views
  • 1 like
  • 3 in conversation