try this one: data few_warehouses; input Prod_ID $ 1-13 Product_Name $15-34 ; cards; 210000000000 Children 210100000000 Children Outdoors 210100100000 Outdoor things, Kids 210200000000 Children Sports 210200100000 A-Team, Kids 220000000000 Children 220100000000 Children Outdoors 220100100000 Outdoor things, Kids 220200000000 Children Sports 220200100000 A-Team, Kids ; proc print;run; data warehouse_locations (keep=Prod_ID Product_Name Product_Line Product_Grp_ID Product_Cat_ID Warehouse); drop PL PG PC; set few_warehouses; format Warehouse $6.; array wrhse {21:22,0:2,0:1} $ _temporary_ ("A2100" "A2101" "A2110" "A2111" "A2120" "A2121" "B2200" "B2201" "B2210" "B2211" "B2220" "B2221"); Product_Line=input(substr(Prod_ID,1,2),2.); /*Using substr function to extract the number of the Product Line*/ Product_Grp_ID=substr(Prod_ID,4,1); /*Using substr function to extract the number of the Group_ID*/ Product_Cat_ID=substr(Prod_ID,12,1); /*Using substr function to extract the Catalog ID*/ PL=Product_Line; /*Setting temp variable PL to Product_Line*/ PG=Product_Grp_ID; PC=Product_Cat_ID; /*Setting temp variable PC to Product_Cat_ID*/ Warehouse=wrhse{PL,PG,PC}; run; proc print;run; Product_ Product_ Product_ Obs Prod_ID Product_Name Warehouse Line Grp_ID Cat_ID 1 210000000000 Children A2100 21 0 0 2 210100000000 Children Outdoors A2110 21 1 0 3 210100100000 Outdoor things, Kids A2110 21 1 0 4 210200000000 Children Sports A2120 21 2 0 5 210200100000 A-Team, Kids A2120 21 2 0 6 220000000000 Children B2200 22 0 0 7 220100000000 Children Outdoors B2210 22 1 0 8 220100100000 Outdoor things, Kids B2210 22 1 0 9 220200000000 Children Sports B2220 22 2 0 10 220200100000 A-Team, Kids B2220 22 2 0 Linlin
... View more