help with the code

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

help with the code


Dear Friends,

I have a data which has a firm identier and a dummy variable SOX. Although most of the firms in my sample have both 0 and 1 values for SOX, some firms have only 0 or 1 value for SOX. I want to delete firms that do not have both 0 or 1 for SOX.

Firm       SOX

A             0

A             1

B             0

B             1

C             0

D             0

D             1

E             1

Expected Output

Firm       SOX

A             0

A             1

B             0

B             1

D             0

D             1

I would appreciate if someone would provide me with the code.

Thank you.


Accepted Solutions
Solution
‎10-08-2012 07:33 PM
Super Contributor
Posts: 1,636

Re: help with the code

data have;

input Firm $      SOX;

cards;

A             0

A             1

B             0

B             1

C             0

D             0

D             1

E             1

;

data want;

  set have;

   by firm;

   if first.firm and last.firm then delete;

   run;

   proc print;run;

View solution in original post


All Replies
Solution
‎10-08-2012 07:33 PM
Super Contributor
Posts: 1,636

Re: help with the code

data have;

input Firm $      SOX;

cards;

A             0

A             1

B             0

B             1

C             0

D             0

D             1

E             1

;

data want;

  set have;

   by firm;

   if first.firm and last.firm then delete;

   run;

   proc print;run;

Contributor
Posts: 28

Re: help with the code

Thank you Linlin.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 180 views
  • 0 likes
  • 2 in conversation