BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello All,
I hope you can help me on this. In my dataset I have siblings and their addresses. I am trying to group all siblings by address, so I know all the siblings who reside at an address. Now in this group I only want to pick the youngest sibling and get that information. I am trying to do this in EG, I have the dataset sorted by mailing address, but I would like to know is there a way where I can get the youngest sibling in the group. (something like select top 1)
Here is my dataset

Address name age
111 street1 child1 5
111 street1 child2 10

In this group I only want to output info for
child1





Thanks for any help
Shri
2 REPLIES 2
RickM
Fluorite | Level 6
I think this would be much easier in a data step after you sort by address and age and then use first.address with by group processing to find the youngest.

Good luck!
art297
Opal | Level 21
Shri,

What do you want to do if the youngest are twins? If you don't confront any twins, or want multiple records in such a case, you could try something like:

proc sql noprint;
create table want as
select *
from have
group by Address
having age eq min(age)
;
quit;

HTH,
Art

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 923 views
  • 0 likes
  • 3 in conversation