title: How to use Boolean datatype in SAS?
body: <p>In many mainstream programming languages you can use Boolean data-type (for instance, value can be either <code>true</code> or <code>false</code>) - to represent binary "true/false".</p>
  
  <p>Is there a Boolean data-type in SAS too?</p>
  
  <p>For example, in this code, the variable <code>is_fruit</code> is meant to represent a binary <code>true</code> (1) or <code>false</code> (0) situation. As I am not aware of any Boolean data-types (or <code>length</code> types), I work around this using numeric:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>Output:</p>
  
  <p><a href="https://i.stack.imgur.com/0Jvm1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Jvm1.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/j8KVk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j8KVk.png" alt="enter image description here"></a></p>
  
  <p>To me this is not a very elegant data structure as the variable <code>is_fruit</code> is really a Boolean data-type (not numeric nor character). So my question is again...</p>
  
  <p>Is there a Boolean data-type (or <code>length</code> type) for the <code>is_fruit</code> above?</p>