selecting data between dates

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

selecting data between dates

Hi,

I am trying to do a couple of things

  1. exclude certain firms (identified by the variable sicid)
  2. select transactions between certain dates

I would like to exclude firms with the SICID between 4900 - 4999 & 6000-6999 i.e. include all other firms

I would only like to include transaction data between 01jan1986 and 31Dec2003

I'm not sure whether I should use if or where statements?

Anyhelp appreciated


Accepted Solutions
Solution
‎10-21-2013 09:28 PM
Frequent Contributor
Frequent Contributor
Posts: 83

Re: selecting data between dates

You have not provided any sample data and sample output. However from your question it seems the following codes would help.

Data want;

set have;

where '01jan1986'd le date '31Dec2003'd;

if  4900 le SICID le  4999 or 6000 le SICID le 6999 then delete;

run;

View solution in original post


All Replies
Solution
‎10-21-2013 09:28 PM
Frequent Contributor
Frequent Contributor
Posts: 83

Re: selecting data between dates

You have not provided any sample data and sample output. However from your question it seems the following codes would help.

Data want;

set have;

where '01jan1986'd le date '31Dec2003'd;

if  4900 le SICID le  4999 or 6000 le SICID le 6999 then delete;

run;

Occasional Contributor
Posts: 15

Re: selecting data between dates

thank you

Trusted Advisor
Posts: 1,131

Re: selecting data between dates

data have;

     set dataset;

     if 4900<=sicid<=4999 or 6000<=sicid<=6999 then delete;

     if '01jan1986'd<=date<='31dec2003'd;

run;

Thanks,

Jagadish

Thanks,
Jag
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 320 views
  • 4 likes
  • 3 in conversation