```Date: Wed, 16 Apr 2003 19:46:08 -0400 Reply-To: "Karl K." Sender: "SAS(r) Discussion" From: "Karl K." Subject: Re: Lookup Table Question You received several good answers, but we SQL-heads always feel obligated to present a "single statement" solution to a problem like this that really is IMHO made-to-order for SQL. data master; input foodnum vita; datalines; 34 6 39 3 42 7 48 12 ; run; data food; input foodnum foodpart1 foodpart2; datalines; 54 34 42 59 39 34 ; run; proc sql; select a.foodnum, b.vita + c.vita as total_vita from food a join master b on a.foodpart1=b.foodnum join master c on a.foodpart2=c.foodnum ; quit; HTH Karl "tomg" wrote in message news:129e284.0304160519.c4f5d98@posting.google.com... > Hi, > Any ideas on a good way to solve this problem? > thanks, tomg > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > INPUT DATA #1: Vitamin A content of four foods. > foodnum vitA > 34 6 > 39 3 > 42 7 > 48 12 > > INPUT DATA #2: These foods are composed of two foods from DATA #1 > > foodnum foodpart1 foodpart2 > 54 34 42 > 59 39 34 > (The foodpart1 and foodpart2 will always be found in foodnum). > > > OUTPUT DATA > foodnum VitA > 54 ? > 59 ? > > We want the VitA computed by finding the Sum of the two foodnums it > is composed of. > For example, > foodnum 54: VitA = 6 (VitA in foodnum 34) > + 7 (VitA in foodnum 42) > ------------- > = 13 > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ```

Back to: Top of message | Previous page | Main SAS-L page