Search code examples
sasdata-manipulationdata-management

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?


Solution

  • 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;