title: How to get unique values for all variables in a dataset
body: <p>I'm using Stata. I have a dataset with approximately 1800 observations and 1050 variables. Most of them are categorical variables with a few categories. It looks something like this:</p>
  <pre><code>------------------------------------------------------
  | id | fh_1 | fh_1a | fh_2 | fh_2a | fh_3 | fh_3a |...
  ------------------------------------------------------
  |1111| 1    |closed | 2    | 4     | 1    | open  |...
  ------------------------------------------------------
  |1112| 2    | open  | 1    | 2     | 3    | closed|...
  ------------------------------------------------------
  .
  .
  .
  
  </code></pre>
  <p>I need to export to an Excel sheet the list of all variables in this dataset with all unique values for each variable. It should look something like this:</p>
  <pre><code>--------------------------
  |variable | unique_values|
  --------------------------
  | fh      | 1 2 3 4 5    |
  --------------------------
  |fh_1a    | closed open  |
  --------------------------
  .
  .
  .
  </code></pre>
  <p>I think I need a loop with the command <code>levelsof</code> but I'm not sure how to build it. Any suggestions?</p>