Konfu Chicken February 2016

Reading in Data into SAS using 'Where' function

For some reason I'm not being able to read in the data properly. I want to be able to read in a large data set but within only specific dates such as Jan 2004 to FEB 2004. My Code is the following:

DATA Work.sales_fact;
SET Work.sales_fact_subset;
WHERE '01JAN2004'd <= Order_Date <= '14FEB2004'd;
RUN;

PROC PRINT;
RUN;

What am I doing incorrectly?

Answers


RamB February 2016

Here is an example of this working.. Please check your dataset.

data want;
set sashelp.rent;
where "01feb1999"d <= date <= "02feb2003"d;
run;


Keni February 2016

If your table names and date structure is correct, your query is correct. Here is a sample of what I did with the correct result set.

 data inputs;
       input Date1 date9. ;
       Format date1 date9.;
       cards;
01JAN2004 
02FEB2004
03MAR2004
04JUN2004
05JUL2004 
    ;



DATA inputss;
SET inputs;
WHERE '01JAN2004'd <= Date1 <= '14FEB2004'd;
RUN;

PROC PRINT;
RUN;

enter image description here


DomPazz February 2016

I think you have DATA and SET switched. DATA is what you want to create. SET is where the data is coming from.

DATA Work.sales_fact_subset ;
SET Work.sales_fact;
WHERE '01JAN2004'd <= Order_Date <= '14FEB2004'd;
RUN;

PROC PRINT data=Work.sales_fact_subset;
RUN;

Post Status

Asked in February 2016
Viewed 2,559 times
Voted 14
Answered 3 times

Search




Leave an answer