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
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;
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.