<p>@Sravan K Reddy's answer is good enough to be a solution, but it is essential to know what is histogram? </p>

<p>Histogram is frequency distribution of datasets and gives statistical information about data. Most commonly used histogram types are; Equi-width and equi-depth which is called equi-height or height-balanced.</p>

<p>In database tools, equi-depth histogram is prefered. ex: Oracle <a href="https://docs.oracle.com/database/121/TGSQL/tgsql_histo.htm#TGSQL379" rel="nofollow noreferrer">see</a></p>

<p>@Sravan K Reddy intends to create equi-width histogram of patent citations. However, in order to create histogram, data must be sorted. That is vital for histogram construction.</p>

<p>If you want to create histogram of your big data, read <a href="https://arxiv.org/pdf/1606.05633.pdf" rel="nofollow noreferrer">this paper</a> and check <a href="https://github.com/tolgabuyuktanir/Equi-DepthHistogramConstroctionDemonstrations" rel="nofollow noreferrer">Apache Pig Scripts</a>.</p>
PIG Item Count and Histogram
<p>This is a two part problem:</p>

<p>PART 1:</p>

<p>I am using the cloudera pig editor to transform my data.  The data set is derived from the US Patents Citations data set.  The first column is the "Cited" patent. The remaining data is the patents that cite the first patent. </p>

<p>3858241 3634889,3557384,3398406,1324234,956203</p>

<p>3858242 3707004,3668705,3319261,1515701</p>

<p>3858243 3684611,3681785,3574238,3221341,3156927,3146465,2949611</p>

<p>3858244 2912700,2838924,2635670,2211676,17445,14040</p>

<p>3858245 3755824,3699969,3621837,3608095,3553737,3176316,2072303</p>

<p>3858246 3601877,3503079,3451067</p>

<p>3858247 3755824,3694819,3621837,2807431,1600859</p>

<p>I need to create PIG code that will count the number of citation that the first patent has.  So, I need the output to be:</p>

<p>3858241 5</p>

<p>3858242 4</p>

<p>3858243 7</p>

<p>3858244 6</p>

<p>3858245 7</p>

<p>3858246 3</p>

<p>3858247 6</p>

<p>PART 2:
I need to create a histogram of the output from problem 1 using a PIG script.</p>

<p>Any help would be greatly appreciated.</p>

<p>Thanks</p>