selecting data between dates

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

selecting data between dates

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;


Accepted Solutions
Solution
‎10-09-2013 11:40 PM
Frequent Contributor
Frequent Contributor
Posts: 83

Re: selecting data between dates

Posted in reply to wschnell1


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


All Replies
Solution
‎10-09-2013 11:40 PM
Frequent Contributor
Frequent Contributor
Posts: 83

Re: selecting data between dates

Posted in reply to wschnell1


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;



Occasional Contributor
Posts: 15

Re: selecting data between dates

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

Really appreciate the help

🔒 This topic is solved and locked.

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

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