BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
user24feb
Barite | Level 11

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

1 ACCEPTED SOLUTION

Accepted Solutions
lipury
SAS Employee

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;

View solution in original post

1 REPLY 1
lipury
SAS Employee

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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Multiple Linear Regression in SAS

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.

Discussion stats
  • 1 reply
  • 806 views
  • 1 like
  • 2 in conversation