Hi, I have two datasets below. In Have1, it lists all products for one industry. Pid is the product ID. Year is the year that the product was introduced. Components are the components of each product. data have1;
input PID $ Year Components $;
datalines;
AA 1995 A15
AA 1995 B15
AA 1995 C36
AA 1995 F25
BB 1996 D14
BB 1996 E41
CC 2005 U14
CC 2005 T11
CC 2005 K14
GG 2005 A15
GG 2005 B15
run; In have2, Pid is the product ID, Fid is the firm that produces the product. Year is the year that this product was introduced and Components are the components in this product. data have2;
input PID $ Fid $ Year Components $;
datalines;
DD 10001 1997 A15
DD 10001 1997 B15
DD 10001 1997 C36
EE 10002 1999 D14
EE 10002 1999 H67
FF 10003 2007 U14
FF 10003 2007 T11
FF 10003 2007 K14
HH 10003 2008 D14
HH 10003 2008 E41
run; I would like to know whether the component combination exists or not compared with its prvious products in the industry. If the component combinations exist in the products that were introduced in the preceding 5 years, the flag is 0. Otherwise, the flag is 1. For example, the component combination of DD (A15, B15, C36) has been presented in previous product AA (A15, B15, C36, F25). So the flag is 0. The component combination of EE (D14, H67) has not shown in previous products, so the flag is 1. The data I want is below. Fid Year Pid Flag 10001 1997 DD 0 10002 1999 EE 1 10003 2007 FF 0 10003 2008 HH 1 What program do I need to use? Thanks.
... View more