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. 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 809 views
  • 0 likes
  • 2 in conversation