I'm working in SAS with an oracle table with a hierarchical codelist column, a COUNT column and a hierarchy indicator column and need to update COUNT column for the parent nodes based on the count of the childs under the node.
ID level code count
1 1 1 (null)
2 2 15 (null)
3 3 156 1
4 2 18 (null)
5 3 181 1
6 3 182 1
7 1 2 (null)
8 2 20 (null)
9 3 205 1
10 3 206 1
NOTE:
the parent nodes should not be counted, only the lowest childs (SO code=1 is count=3, code=2 is count=2)
the "lowest" child nodes have a preset count of one, I need to update the NULL values.
- the codelist is 1 to 10 characters long. So 9 hierarchical levels of parents.
- I would prefer a PROC SQL workaround
I tried to create a temporary SAS dataset and UPDATE - SET = (SELECT COUNT) WHERE with a SUBSTR function in the select, but couldn't figure out how to make it work for every hierarchy level.