SAS Tip: Use the BETWEEN-AND Operator to Search an Inclusive Range of Values (Daily tip for 2024-Jul-19)

The BETWEEN-AND operator can be used inside of a where statement to determine if the value of a variable is contained within an inclusive range:

proc print data=sashelp.retail;
    where year between 1980 and 1984;

Notice that the boundaries that you give are always included in the range, so in this case the data from 1980 and 1984 is printed, along with data from 1981-1983.


This tip was originally posted by Mary Rosenbloom on

READ this complete tip   Visit a random SAS tip

Start a topic
About these Tips
A "SAS tip" is a basic unit of information exchange between SAS users. The tips on this board come from, from SAS user conferences, from SAS blogs, and from freelance contributions from SAS users like you. We hope that you're able to always learn something new here!

» How you can contribute

Tip-o-meter: 63 tips