title: How to loop using Pig for unique values
body: <p>I have a file that contains the census information which I would like to query using Pig.</p>
  
  <p>The file format is as follows:</p>
  
  <pre><code>ID Name Year Gender State Count
  
  1 Jones 1980   M      MA   100
  </code></pre>
  
  <p>I would like to get the percentage for each name for that state in that year for each year in the file</p>
  
  <p>How can I loop through each of the years and calculate for each state the percentage of occurrences of each name?</p>
  
  <p>The result should look as follows:</p>
  
  <pre><code>    1901 Jones MA 2%
      1901 Jones VT 3%
      1901 Smith MA 1%
      1901 Lee   VT 4%
      ....
      ....
  
      2016 Jones MA 2%
      2016 Jones VT 3%
      2016 Smith MA 1%
      2016 Lee   VT 4%
  </code></pre>
  
  <p>For every year in the table I need to break it down by state and within every state I need to calculate the percentage for each name given the count information. </p>