- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to keep only CEO's in my dataset (as opposed to CEO's and other executives). How can I use a keep statement to drop anything in the CEOANN column that isn't "CEO"?
Here's the code I tried:
data paper.Compustat_ExecuComp;
set paper.Compustat_ExecuComp;
if CEOANN = "CEO" then keep;
run;
Any suggestions? Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, KEEP is a compile time statement that impacts the Program Data Vector being built to hold the data before it is written to disk.
What you want to do is OUTPUT when your condition is met.
However, I recommend that you do NOT use the same name in both your input and output datasets because you will lose all your original data and will not be able to go back to it.
For a model of how to output only the rows for Females to one file and the rows for Males to a different file, see this example using SASHELP.CLASS:
data class_males
class_females;
set sashelp.class;
if sex = 'F' then output class_females;
else if sex = 'M' then output class_males;
run;
proc print data=class_females;
title 'Female Students';
run;
proc print data=class_males;
title 'Male Students';
run;
title;
cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, KEEP is a compile time statement that impacts the Program Data Vector being built to hold the data before it is written to disk.
What you want to do is OUTPUT when your condition is met.
However, I recommend that you do NOT use the same name in both your input and output datasets because you will lose all your original data and will not be able to go back to it.
For a model of how to output only the rows for Females to one file and the rows for Males to a different file, see this example using SASHELP.CLASS:
data class_males
class_females;
set sashelp.class;
if sex = 'F' then output class_females;
else if sex = 'M' then output class_males;
run;
proc print data=class_females;
title 'Female Students';
run;
proc print data=class_males;
title 'Male Students';
run;
title;
cynthia