Please help me with selecting record from a certain date range. The variable is Comp_Date (formatted already as a date) and I want to select (e.g. 20, 30...) records to view all with all of the other variables.
Thanks.
Using sashelp.Stocks as an example as no data is provided:
data stocks;
set sashelp.stocks (obs=30 where =( '01Jan1990'd <= date <= '31Dec1995'd));
run;
Log:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data stocks;
70 set sashelp.stocks (obs=30 where =( '01Jan1990'd <= date <= '31Dec1995'd));
71 run;
NOTE: There were 30 observations read from the data set SASHELP.STOCKS.
WHERE (date>='01JAN1990'D and date<='31DEC1995'D);
NOTE: The data set WORK.STOCKS has 30 observations and 8 variables.
@Jallah_Kennedy wrote:
Please help me with selecting record from a certain date range. The variable is Comp_Date (formatted already as a date) and I want to select (e.g. 20, 30...) records to view all with all of the other variables.
Thanks.
20 or 30 is not a "date range". A date range would typically refer to a start date value and and end date value. Is that what you want?
If so, what range specifically do you want?
Using sashelp.Stocks as an example as no data is provided:
data stocks;
set sashelp.stocks (obs=30 where =( '01Jan1990'd <= date <= '31Dec1995'd));
run;
Log:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data stocks;
70 set sashelp.stocks (obs=30 where =( '01Jan1990'd <= date <= '31Dec1995'd));
71 run;
NOTE: There were 30 observations read from the data set SASHELP.STOCKS.
WHERE (date>='01JAN1990'D and date<='31DEC1995'D);
NOTE: The data set WORK.STOCKS has 30 observations and 8 variables.
@Jallah_Kennedy wrote:
Please help me with selecting record from a certain date range. The variable is Comp_Date (formatted already as a date) and I want to select (e.g. 20, 30...) records to view all with all of the other variables.
Thanks.
Thanks you so much. It worked. Much appreciated.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.