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.
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;
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;
Thank you Linlin.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.