- data b;
- set a;
- by firm year;
- if first.firm then sum=0;
- if export=0 then sum+1;
- if sum=0 then delete;
- run;
- data c;
- set b(drop=sum);
- by firm year;
- if first.firm then sum=0;
- if export^=0 then sum+1;
- if sum=0 then delete;
- run;
- data d;
- set c(drop=sum);
- by firm year;
- array aa{4} export1-export4;
- export1=lag(export);
- export2=lag2(export);
- export3=lag3(export);
- export4=lag4(export);
- do i=1 to 4;
- if aa(i)=. then aa(i)=0;
- if i>t then aa(i)=0;
- end;
- if first.firm then do; t=1;
- exit=0;export1=0;export2=0;export3=0;export4=0;
- end;
- else t+1;
- if export1*export2^=0 and export=0 then exit=1;
- else if export=0 and export1=0 and export2=0 and export3^=0 and export4=0 then exit=1;
- else exit=0;
- if export2*export3^=0 and export=0 then delete;
- if export3*export4^=0 and export=0 then delete;
- if export=0 and export1=0 and export2=0 and export3=0 then delete;
- run;
- data e;
- set d(keep=firm year export exit);
- by firm year;
- exit1=lag(exit);
- if first.firm then group_in_firm=1;
- if exit1-exit=1 then group_in_firm+1;
- run;
- data f;
- set e(drop=exit1);
- by firm group_in_firm;
- if first.group_in_firm then num_in_group=1;
- else num_in_group+1;
- run;


雷达卡






京公网安备 11010802022788号







