BookmarkSubscribeRSS Feed
ANLYNG
Pyrite | Level 9

Hi,

 

I got a input dataset (companies with 1 or many owners in unknown number of levels). I got the following variables in the input dataset:

 

childID, ratio, from_date to_date , parentID ratio

 

I need the ancestors for each children per day (or period) relations with stated owner_ratio. Eg. For the days in 2017. There can be many levels in the hierarchy. Each child owns ratio in the parent companies.

I want the output the be something like this:

Day childID owner_ratio  parentID  parentID owner_ratio    parent_to_parent_ID parent_to_parent_ratio parent_to_parent_parent_ratio

Do anyone have ideas/code to solve it? Can it be done in the same data step (parent child resolving) eller do I have to merge the extra wanted data in the output after the hierachi has been resolved.

 

Thanks in advance.

1 REPLY 1
Reeza
Super User

There are tree based solutions on here that would group a family into a the correct groups though it won't set up the data in the structure you wanted. 

 

https://gist.github.com/statgeek/14e3aa2a9f718f551cd98134e9ceed30

 

This isn't a particular easy problem to solve because of the recursive nature. If you have issues please post your code to the forum including sample data so we can easily help you out. 

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
  • 1 reply
  • 627 views
  • 0 likes
  • 2 in conversation