BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emma8
Quartz | Level 8
Hi. I would like to select distinct values from 3 datasets without merging it,
For example,
Age variable from 3 datasets:
Data 1 data 2 data 3
1 4 7
3 5 8
5 7 9
1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

The problem could be solved by using data-step merge without by ... why don't you want to use merge?

 

proc sort data=a out=a_sorted(keep=Age) nodupkey;
	by Age;
run;

proc sort data=b out=b_sorted(keep=Age) nodupkey;
	by Age;
run;

proc sort data=c out=c_sorted(keep=Age) nodupkey;
	by Age;
run;

data compare;
	merge
		a_sorted(rename=(Age = Age_A))
		b_sorted(rename=(Age = Age_B))
		c_sorted(rename=(Age = Age_C))
	;
run;

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

Would the desired result be a list of distinct values per data set or the list of distinct values over all data sets?

Emma8
Quartz | Level 8
District values over all datasets.—I would like to compare across column and rows so—it would nice if formatted as in my first message notes. Thank you.
andreas_lds
Jade | Level 19

The problem could be solved by using data-step merge without by ... why don't you want to use merge?

 

proc sort data=a out=a_sorted(keep=Age) nodupkey;
	by Age;
run;

proc sort data=b out=b_sorted(keep=Age) nodupkey;
	by Age;
run;

proc sort data=c out=c_sorted(keep=Age) nodupkey;
	by Age;
run;

data compare;
	merge
		a_sorted(rename=(Age = Age_A))
		b_sorted(rename=(Age = Age_B))
		c_sorted(rename=(Age = Age_C))
	;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 409 views
  • 1 like
  • 3 in conversation