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

Hello,

I have a large data set that I need to subset the data set between two specific dates. I would need to get the sales data only from 01/01/2005 to 12/31/2005.

Data set name: sales

variable name: sales_date

variable name: sold_item

variable name: quantity

------------------------------------------------------

sales_date | sold_item | quantity

12/24/2003 | printer | 233

11/10/2005 | printer | 130

07/24/2005 | phone | 256

09/26/2005 | ipad | 239

01/24/2006 | ipad | 542

01/17/2006 | notebook | 328

Thanks,

Roger

1 ACCEPTED SOLUTION

Accepted Solutions
overmar
Obsidian | Level 7

Essentially,

proc sql;

create table want as

select *

from have

where sales_date between '01JAN2012'd and '31DEC2012'd;

quit;

OR you could do it in data step.

data want;

     set have;

     where '01JAN2012'd<=sales_date<='31DEC2012'd;

run;

View solution in original post

2 REPLIES 2
umashankersaini
Quartz | Level 8

Hi Roger,

Have you tried with Proc sql with where clause includeing between and and.

like : where sales_date between  12/24/2003 and 07/24/2005

Regards

Uma Shanker Saini

overmar
Obsidian | Level 7

Essentially,

proc sql;

create table want as

select *

from have

where sales_date between '01JAN2012'd and '31DEC2012'd;

quit;

OR you could do it in data step.

data want;

     set have;

     where '01JAN2012'd<=sales_date<='31DEC2012'd;

run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 12198 views
  • 5 likes
  • 3 in conversation