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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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