## Proc bom option to give the lowest level

Solved
Super Contributor
Posts: 346

# Proc bom option to give the lowest level

Hello,

I might have overlooked something (summary output?), but is there a standard option which only gives me the lowest level (=raw materials) of a bom and filters out the intermediate products. Does it exist and is there an example for it?

I mean the data step at the end:

``````Data PS;
Input @1 Material \$7. @9 Component \$7. @17 Qty 8.;
Datalines;
2001234 4601234 0.3
2001234 4601235 0.2
2001234 4601236 0.4
2001234 4100001 0.05
2001234 4000000 0.15
4601234 4000123 0.5
4601234 4000124 0.5
4601235 8000123 1
4601236 4500000 0.8
4601236 4500001 0.2
;
Run;

Proc SQL;
Create Table PS_2 As
Select Distinct a.Component As Material, '' As Component Length=7, . As Qty
From PS a
Left Join PS b
On a.Component=b.Material
Where Missing (b.Material);
Quit;

Proc Append Base=PS Data=PS_2; Run;

Proc BOM Data=PS
Out=Res;
Structure / Parent=Material
Component=Component
Quantity=Qty
EndItem=('2001234');
Run;

* Standard procedure which is quicker than this ?;
Data Res;
Length Lowest \$3.;
Set Res End=Eof;
If not Eof Then Set Res (Firstobs=2 Keep=_LEVEL_ Rename=(_LEVEL_=_LEVEL_SUCC_));
If _LEVEL_ ge _LEVEL_SUCC_ Then Lowest='YES';
Run;``````

Thanks&kind regards

Accepted Solutions
Solution
‎01-15-2016 07:09 AM
SAS Employee
Posts: 11

## Re: Proc bom option to give the lowest level

I've included a couple more ways of obtaining the leaves from the proc BOM output below. The primary developer of BOM will return to work next week and might have some more suggestions.

Thanks!

Lindsey

proc sql;

select * from res where part_id not in (select distinct paren_id from res);

quit;

proc netdraw data=res out=ndout(where=(_X_ eq 1 and _SEQ_ eq 0)) nodisplay;

actnet / activity=part_id successor=paren_id id=(_part_);

run;

proc print data=ndout; run;

All Replies
Solution
‎01-15-2016 07:09 AM
SAS Employee
Posts: 11

## Re: Proc bom option to give the lowest level

I've included a couple more ways of obtaining the leaves from the proc BOM output below. The primary developer of BOM will return to work next week and might have some more suggestions.

Thanks!

Lindsey

proc sql;

select * from res where part_id not in (select distinct paren_id from res);

quit;

proc netdraw data=res out=ndout(where=(_X_ eq 1 and _SEQ_ eq 0)) nodisplay;

actnet / activity=part_id successor=paren_id id=(_part_);

run;

proc print data=ndout; run;

🔒 This topic is solved and locked.