Asked • 04/12/19

How to use Boolean datatype in SAS?

In many mainstream programming languages you can use Boolean data-type (for instance, value can be either `true` or `false`) - to represent binary "true/false". Is there a Boolean data-type in SAS too? For example, in this code, the variable `is_fruit` is meant to represent a binary `true` (1) or `false` (0) situation. As I am not aware of any Boolean data-types (or `length` types), I work around this using numeric: data is_fruit; length fruit_name $ 40 is_fruit 8.; input fruit_name $ is_fruit; datalines; apple 1 orange 1 car 0 tree 0 chicken 0 peach 1 mango 1 human 0 ; run; Output: [![enter image description here][1]][1] [![enter image description here][2]][2] To me this is not a very elegant data structure as the variable `is_fruit` is really a Boolean data-type (not numeric nor character). So my question is again... Is there a Boolean data-type (or `length` type) for the `is_fruit` above? [1]: http://i.stack.imgur.com/0Jvm1.png [2]: http://i.stack.imgur.com/j8KVk.png

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.