BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wschnell1
Calcite | Level 5

Hi,

I would like to select data between two dates and then exclude certain firms within those dates.

Dates are identified by TRANDATE (i.e. transaction date)

Firm I.D is based of the variable SIC

I tried to perform this in two steps because I wasn't sure how to do this in one.

I keep unfortunately getting error msg's

data subsamp1;

  set table1;

  if TRANDATE between '01jan1986'd and '31Dec2003'd then delete;

run;

data   subsamp2;

  set subsamp1;

  if 4900<= SIC <= 4999 or

  6000<= SIC <= 6999 then delete;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Mit
Calcite | Level 5 Mit
Calcite | Level 5


Hi There,

You have started a new thread. Try this code

data keep reject;
set table1;
if 4900 le SIC le 4999  or 6000 le SIC le 6999 then output reject;
else if '01jan1986'd le TRANDATE le '31Dec2003'd then  output reject;
else output keep;

run;



View solution in original post

2 REPLIES 2
Mit
Calcite | Level 5 Mit
Calcite | Level 5


Hi There,

You have started a new thread. Try this code

data keep reject;
set table1;
if 4900 le SIC le 4999  or 6000 le SIC le 6999 then output reject;
else if '01jan1986'd le TRANDATE le '31Dec2003'd then  output reject;
else output keep;

run;



wschnell1
Calcite | Level 5

Thanks so much... as you can probably tell i'm pretty new to this.

Really appreciate the help

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1045 views
  • 1 like
  • 2 in conversation