title: SAS output statement and keep statement
body: <p>I run a program like this:</p>
  
  <pre><code>data january;
  set allmonths (keep=product month num_sold cost);
  if month='jan' then output january;
  sales=num_sold*cost;
  put sales;
  keep product sales;
  run;
  </code></pre>
  
  <p>The dataset january contains two variables: product and sales. But sales value is missing. </p>
  
  <pre><code>product sales
  a        .
  </code></pre>
  
  <p>I kind of understand why sales value is missing because it is not defined in the dataset allmonth before output statement.</p>
  
  <p>Then why this variable can be included in the dataset january if output statement doesn't have it. Keep statement can include every variable listed to every dataset, then why no value be written to the dataset.</p>
  
  <p>I think I might know the reason. Keep statement is about variables, output is about observations. </p>
  
  <p>But I still want to ask and learn.</p>
  
  <p>Thank you!</p>