# Monthly Archives: September 2017

## How to convert numeric date to Stata date

Category:Uncategorized

Real-life data can come in a variety of formats.  In this post, I would like to show how to convert a numeric date to Stata date.

## The problem

Let’s use an example.  Say that we have date variable in the following format and we want to convert it to Stata format.

``` +----------+
| datevar  |
|----------|
| 20170520 |
| 20170521 |
| 20170522 |
| 20170524 |
| 20170524 |
+----------+

```

## The Solution

There are two steps involved to convert the numeric variable to Stata format. These are:

```tostring date, replace
gen date2 = date(datevar, "YMD")
format date2 %td
```

## Explanation

The first line of code converts the numeric variable to string variable. This is necessary as the date function can work only on string variables. The second line of code uses the date function to generate a new variable date2 from the existing variable datevarThe “YMD” specifies how the datevar has the sorting of year, month, and day. The last line of code just formats the new variable so that human can easily read it.

## T-bills rates, auction dates, bids and offer prices

Category:Uncategorized Tags :
 Auction No. Auction Date Realized Amount 3-Months 6-Months 12-Months 1st 6/25/1998 23,623.24 15.70% 2nd 7/14/1998 7,708.23 14.62% 15.41% 16.00% 3rd 7/23/1998 2,305.36 15.74% 4th 8/5/1998 21,261.33 13.82% 15.29% 15.90% 5th 8/18/1998 19,628.07 13.71% 14.94% 15.78% 6th 9/4/1998 20,526.84 13.85% 15.39% 7th 9/29/1998 9,255.20 13.55% 15.17% 8th 10/12/1998 1,910.04 15.18% 9th 10/23/1998 10th 11/4/1998 23,149.34 14.13% 11th 11/16/1998 6,981.53 9.50% 11.96% 12.99% 12th 12/4/1998 5,998.96 11.93% 12.99% 13th 12/22/1998 2,207.54 11.87% 12.98% 14th 1/10/1999 5,310.86 12.10% 12.98% 15th 1/20/1999 8,364.98 12.11% 12.46% 13.17% 16th 2/1/1999 20,217.27 12.43% 12.87% 13.54% 17th 2/14/1999 15,086.10 12.71% 13.30% 13.81% 18th 3/3/1999 10,978.54 12.37% 12.96% 19th 3/25/1999 3,860.06 10.73% 11.35% 11.80% 20th 4/21/1999 211.15 10.60% 11.50% 21st 5/12/1999 22nd 5/26/1999 2,449.45 8.37% 23rd 6/9/1999 10,210.51 7.53% 24th 6/23/1999 12,580.09 6.66% 10.10% 25th 7/7/1999 2,063.78 10.33% 26th 7/21/1999 6,403.10 6.96% 10.29% 27th 8/11/1999 15,569.91 6.94% 10.18% 28th 8/25/1999 9,919.75 7.86% 9.43% 10.20% 29th 9/8/1999 17,856.24 8.80% 10.05% 10.32% 30th 9/22/1999 5,428.64 8.96% 10.25% 10.73% 31st 10/6/1999 2,187.07 10.36% 32nd 10/20/1999 33rd 11/3/1999 26,708.09 8.78% 9.94% 10.61% 34th 11/17/1999 5,884.40 8.82% 10.13% 10.87% 35th 12/1/1999 1,742.63 8.87% 10.16% 10.77% 36th 12/15/1999 1,833.81 10.10% 10.33% 37th 12/29/1999 201.77 10.31% 38th 1/12/2000 95.94 8.49% 39th 1/26/2000 2,719.69 8.01% 8.43% 8.95% 40th 2/9/2000 8,746.78 7.54% 7.96% 8.44% 41st 2/23/2000 2,642.95 7.29% 7.45% 7.90% 42nd 3/8/2000 71.35 7.89% 43rd 3/23/2000 870.03 7.29% 7.44% 7.89% 44th 4/5/2000 8,318.59 7.11% 7.20% 7.69% 45th 4/19/2000 4,674.80 6.98% 7.13% 7.59% 46th 5/3/2000 20,762.14 6.94% 7.09% 7.58% 47th 5/17/2000 2,263.23 6.98% 7.20% 7.62% 48th 5/31/2000 1,198.66 6.95% 7.22% 7.61% 49th 6/14/2000 984.3 6.93% 50th 6/28/2000 51st 7/12/2000 8,750.29 6.85% 7.14% 52nd 7/26/2000 7,780.42 7.03% 7.23% 7.78% 53rd 8/9/2000 698.65 7.38% 7.96% 54th 8/23/2000 1,520.62 7.38% 8.01% 55th 9/6/2000 255.08 7.45% 8.10% 56th 9/20/2000 11,834.92 7.95% 8.14% 8.93% 57th 10/4/2000 11,036.69 10.23% 10.47% 10.91% 58th 10/18/2000 189.6 11.00% 59th 11/1/2000 12,790.27 10.99% 11.48% 60th 11/15/2000 426.69 10.96% 61st 11/29/2000 993.03 10.92% 11.49% 62nd 12/13/2000 585.28 10.96% 11.49% 63rd 1/10/2001 64th 1/24/2001 5,217.19 10.50% 10.96% 65th 2/7/2001 2,861.88 10.50% 10.96% 11.44% 66th 2/21/2001 2,926.20 10.96% 67th 3/7/2001 7,510.58 10.96% 68th 3/21/2001 13,203.74 11.16% 11.55% 11.95% 69th 4/5/2001 18,511.96 11.08% 11.54% 11.96% 70th 4/18/2001 4,392.58 11.54% 11.98% 71st 5/2/2001 19,718.56 11.13% 11.51% 11.97% 72nd 5/16/2001 4,252.95 11.57% 11.98% 73rd 5/30/2001 20,613.56 11.17% 11.60% 11.99% 74th 6/13/2001 10,915.78 11.79% 12.17% 12.53% 75th 6/27/2001 15,491.42 12.22% 12.88% 12.94% 76th 7/11/2001 6,132.91 12.15% 12.56% 77th 7/25/2001 11,315.59 11.33% 11.58% 11.98% 78th 8/8/2001 8,415.58 11.17% 11.36% 11.73% 79th 8/22/2001 16,532.72 10.04% 10.47% 10.82% 80th 9/5/2001 11,430.17 10.22% 10.49% 10.84% 81st 9/19/2001 1,178.84 10.18% 10.50% 10.87% 82nd 10/3/2001 7,737.85 10.00% 10.40% 10.76% 83rd 10/17/2001 3,231.11 10.29% 10.72% 84th 10/31/2001 9,208.18 8.18% 8.50% 9.00% 85th 11/14/2001 7,508.83 7.96% 8.30% 8.90% 86th 11/28/2001 9,806.76 7.96% 8.26% 8.74% 87th 12/12/2001 2,622.99 8.14% 8.54% 88th 12/26/2001 9,307.36 7.65% 7.93% 8.40% 89th 1/9/2002 8,089.56 7.77% 8.20% 90th 1/23/2002 11,744.50 6.13% 6.35% 6.82% 91st 2/6/2002 24,777.97 5.36% 5.65% 6.38% 92nd 2/20/2002 13,093.08 6.39% 6.90% 93rd 3/6/2002 11,392.48 5.81% 6.47% 7.01% 94th 3/20/2002 25,575.82 5.74% 6.44% 6.95% 95th 4/3/2002 3,693.80 6.48% 7.01% 96th 4/17/2002 5,882.04 6.45% 6.98% 97th 5/1/2002 32,973.06 5.77% 6.38% 6.96% 98th 5/15/2002 38,733.14 6.39% 6.95% 99th 5/29/2002 9,142.53 5.80% 6.43% 6.97% 100th 6/12/2002 4,105.12 6.42% 6.99% 101st 6/26/2002 10,520.51 6.28% 102nd 7/10/2002 66,055.70 5.81% 6.27% 6.82% 103rd 7/24/2002 10,417.33 6.40% 104th 8/7/2002 27,909.56 6.40% 105th 8/21/2002 24,642.81 5.80% 6.94% 106th 9/4/2002 17,080.61 6.39% 107th 9/18/2002 26,314.81 6.37% 108th 10/2/2002 109th 10/16/2002 19,144.33 6.34% 110th 10/30/2002 37,434.87 6.87% 111th 11/13/2002 20,936.25 6.36% 112th 11/27/2002 24,469.00 4.76% 113th 12/11/2002 12,970.31 4.32% 114th 12/25/2002 19,324.67 3.90% 4.36% 115th 1/8/2003 33,164.54 3.84% 116th 1/22/2003 27,601.98 3.18% 3.63% 117th 2/5/2003 43,925.37 3.19% 118th 2/19/2003 9,887.64 3.17% 3.60% 119th 3/5/2003 30,333.65 2.09% 120th 3/19/2003 40,237.07 1.96% 2.66% 121st 4/2/2003 4,116.36 1.64% 122nd 4/16/2003 24,308.65 1.66% 2.61% 123rd 5/1/2003 12,100.75 1.65% 124th 5/15/2003 40,882.17 2.58% 125th 5/28/2003 23,489.29 1.80% 126th 6/11/2003 25,403.20 2.36% 127th 6/25/2003 1,487.65 1.66% 128th 7/9/2003 75,718.12 1.66% 2.15% 129th 7/23/2003 26,937.27 1.21% 130th 8/6/2003 51,353.89 0.99% 1.40% 131st 8/20/2003 36,479.06 1.21% 132nd 9/3/2003 19,484.35 1.38% 1.93% 133rd 9/17/2003 14,434.33 1.61% 134th 10/1/2003 1,494.90 1.47% 135th 10/15/2003 136th 10/29/2003 38,469.42 1.46% 1.95% 137th 11/12/2003 198.36 1.66% 138th 11/30/2003 196.16 1.98% 139th 12/10/2003 297.56 1.64% 140th 12/25/2003 196.12 1.99% 141st 1/7/2004 8,232.56 1.64% 142nd 1/21/2004 9,918.87 1.48% 1.96% 143rd 2/11/2004 29,324.50 1.68% 144th 2/18/2004 39,155.67 1.49% 1.97% 145th 3/3/2004 18,276.83 1.74% 146th 3/17/2004 41,124.52 1.52% 2.00% 147th 3/31/2004 20,500.73 1.80% 148th 4/14/2004 16,814.94 1.61% 2.07% 149th 4/28/2004 990.9 1.84% 150th 5/12/2004 57,159.13 1.70% 2.19% 151st 5/26/2004 1,583.61 2.08% 152nd 6/9/2004 153rd 6/23/2004 154th 7/7/2004 65,185.55 2.02% 2.69% 155th 7/21/2004 66,908.30 2.52% 156th 8/4/2004 50,888.52 2.13% 2.83% 157th 8/18/2004 46,789.58 2.62% 158th 9/1/2004 61,055.09 2.23% 2.97% 159th 9/15/2004 1,083.79 3.00% 160th 9/29/2004 17,332.44 2.95% 161st 10/13/2004 1,230.44 3.19% 162nd 10/27/2004 20,194.27 3.22% 3.84% 163rd 11/10/2004 2,405.24 3.73% 164th 11/24/2004 26,261.46 3.78% 4.43% 165th 12/8/2004 166th 12/22/2004 15,113.79 3.92% 167th 1/5/2005 26,892.39 4.16% 168th 1/23/2005 77,002.01 4.14% 4.96% 169th 2/2/2005 976.65 4.79% 170th 2/16/2005 62,346.87 4.70% 5.49% 171st 3/2/2005 15,421.34 5.18% 172nd 3/16/2005 78,792.50 4.94% 5.72% 173rd 3/30/2005 21,947.34 5.51% 174th 4/13/2005 98,772.43 5.81% 7.10% 175th 4/27/2005 7,881.90 7.08% 176th 5/11/2005 86,138.23 7.03% 7.91% 177th 5/25/2005 40.95 7.82% 178th 6/8/2005 490.85 7.38% 7.90% 8.30% 179th 6/22/2005 105,576.70 7.48% 7.94% 8.40% 180th 7/6/2005 76,414.86 7.55% 7.98% 8.46% 181st 7/20/2005 17,443.35 7.69% 7.97% 8.69% 182nd 8/3/2005 54,781.02 7.75% 8.02% 8.70% 183rd 8/17/2005 14,152.57 7.84% 8.11% 8.79% 184th 8/31/2005 105,887.67 7.99% 8.12% 8.78% 185th 9/14/2005 9,269.17 8.10% 8.14% 8.79% 186th 9/28/2005 8,232.56 8.10% 8.14% 8.79% 187th 10/12/2005 4,270.70 8.10% 8.14% 8.79% 188th 10/26/2005 18,476.57 8.10% 8.14% 8.77% 189th 11/8/2005 7,063.96 8.10% 8.14% 8.77% 190th 11/23/2005 57,208.62 8.10% 8.26% 8.77% 191st 12/7/2005 18,020.78 8.79% 192nd 12/21/2005 68,479.04 8.09% 8.25% 8.76% 193rd 1/4/2006 46,726.17 8.10% 8.27% 8.78% 194th 1/18/2006 8,447.61 8.10% 8.29% 8.75% 195th 2/1/2006 14,161.78 8.10% 8.29% 8.78% 196th 2/15/2006 5,868.49 8.10% 8.79% 197th 3/1/2006 7,477.28 8.10% 8.29% 8.78% 198th 3/15/2006 25,003.28 8.10% 8.29% 8.78% 199th 3/29/2006 37,463.37 8.10% 8.29% 8.79% 200th 4/12/2006 13,663.76 8.10% 8.29% 8.79% 201st 4/26/2006 459.7 8.79% 202nd 5/10/2006 653.88 8.10% 8.29% 8.79% 203rd 5/24/2006 1,113.60 8.10% 8.29% 8.79% 204th 6/7/2006 25,711.77 8.25% 8.42% 8.79% 205th 6/21/2006 5,399.03 8.33% 8.49% 8.79% 206th 7/5/2006 76,207.78 8.31% 8.49% 8.79% 207th 7/19/2006 14,754.83 8.33% 8.49% 8.79% 208th 8/2/2006 6,263.67 8.61% 8.81% 9.00% 209th 8/16/2006 11,452.90 8.63% 8.81% 9.00% 210th 8/30/2006 11,086.99 8.64% 8.81% 9.00% 211th 9/13/2006 19,786.91 8.64% 8.81% 9.00% 212th 9/27/2006 17,966.59 8.64% 8.81% 9.00% 213th 10/11/2006 15,367.91 8.64% 8.81% 9.00% 214th 10/21/2006 21,623.30 8.64% 8.81% 9.00% 215th 11/8/2006 44,883.38 8.64% 8.82% 9.00% 216th 11/22/2006 60,680.82 8.64% 8.81% 9.00% 217th 12/6/2006 37,050.33 8.64% 8.81% 9.00% 218th 12/20/2006 16,450.42 8.64% 8.81% 9.00% 219th 12/30/2006 34,271.89 8.64% 8.81% 9.00% 220th 1/17/2007 36,088.07 8.64% 8.81% 9.00% 221st 1/31/2007 70,358.36 8.64% 8.81% 9.00% 222nd 2/14/2007 48,419.52 8.64% 8.81% 9.00% 223rd 2/28/2007 37,515.55 8.64% 8.81% 9.00% 224th 3/14/2007 24,821.43 9.00% 225th 3/28/2007 45,259.22 8.65% 8.83% 9.02% 226th 4/11/2007 52,094.66 8.69% 8.87% 9.05% 227th 4/25/2007 47,802.52 8.69% 8.90% 9.08% 228th 5/9/2007 19,515.83 8.69% 8.90% 9.09% 229th 5/23/2007 7,322.27 8.69% 8.90% 9.10% 230th 6/7/2007 42,948.92 8.90% 9.12% 231st 6/21/2007 7,330.40 9.16% 232nd 7/4/2007 56,426.11 8.69% 8.90% 9.16% 233rd 7/18/2007 52,869.76 8.90% 9.16% 234th 8/1/2007 9,644.55 9.10% 9.37% 235th 8/15/2007 30,734.26 9.05% 9.14% 9.40% 236th 8/29/2007 5,485.80 9.40% 237th 9/12/2007 23,058.65 9.40% 238th 9/26/2007 19,383.16 9.40% 239th 10/10/2007 15,497.11 9.40% 240th 10/24/2007 9,366.71 9.14% 9.40% 241st 11/7/2007 32,230.74 9.14% 9.39% 242nd 11/21/2007 11,458.84 9.21% 9.40% 243rd 12/5/2007 45,158.40 9.11% 9.22% 9.41% 244th 12/19/2007 6,714.09 9.12% 9.26% 9.44% 245th 1/2/2008 23,597.09 9.09% 9.25% 9.44% 246th 1/16/2008 7,049.43 9.30% 9.45% 247th 1/30/2008 248th 2/13/2008 45,576.88 9.38% 9.61% 9.87% 249th 2/27/2008 35,434.70 9.46% 9.74% 9.99% 250th 3/12/2008 28,217.88 9.55% 9.82% 10.08% 251st 3/26/2008 9.08 10.12% 252nd 4/9/2008 37,677.86 9.56% 9.87% 10.13% 253rd 4/23/2008 516.94 9.87% 10.14% 254th 5/7/2008 29,523.08 9.67% 9.89% 10.17% 255th 5/21/2008 3,505.35 9.95% 10.32% 256th 6/4/2008 63,460.37 10.98% 11.19% 11.39% 257th 6/18/2008 15,198.29 11.32% 11.47% 11.69% 258th 7/2/2008 76,844.14 11.45% 11.78% 259th 7/16/2008 52,613.62 11.65% 11.83% 260th 7/30/2008 39,951.17 12.17% 261st 8/13/2008 35,999.61 12.22% 262nd 8/27/2008 34,712.03 12.39% 263rd 9/10/2008 14,759.57 12.56% 264th 9/24/2008 34,264.95 12.56% 12.69% 265th 10/8/2008 51,111.02 12.55% 266th 10/22/2008 60,782.88 12.56% 12.66% 12.79% 267th 11/5/2008 51,540.01 12.91% 268th 11/19/2008 103,467.68 13.69% 14.01% 269th 12/3/2008 81,473.36 13.84% 14.01% 270th 12/17/2008 70,543.29 13.84% 14.01% 271st 12/31/2008 67,795.02 13.85% 14.00% 14.25% 272nd 1/14/2009 79,356.69 13.85% 14.01% 14.26% 273rd 1/28/2009 79,504.93 13.73% 14.00% 14.16% 274th 2/11/2009 155,220.30 13.46% 13.74% 13.84% 275th 2/25/2009 124,923.53 12.56% 12.96% 12.99% 276th 3/11/2009 111,094.24 11.48% 11.67% 11.78% 277th 3/25/2009 81,395.94 11.65% 11.77% 11.85% 278th 4/8/2009 63,107.59 12.53% 12.76% 12.97% 279th 4/22/2009 64,724.62 12.89% 12.95% 13.14% 280th 5/6/2009 71,772.24 12.97% 13.11% 13.23% 281st 5/20/2009 29,489.02 13.14% 13.26% 282nd 6/3/2009 53,578.79 13.14% 13.23% 283rd 6/17/2009 56,979.58 12.01% 12.09% 284th 7/15/2009 58,349.25 11.31% 11.38% 11.47% 285th 7/29/2009 44,266.78 11.75% 286th 8/12/2009 79,908.16 12.16% 287th 8/26/2009 39,622.53 12.36% 12.44% 12.42% 288th 9/9/2009 51,657.20 12.43% 12.58% 12.46% 289th 9/25/2009 59,418.83 12.44% 12.58% 12.48% 290th 10/7/2009 23,392.02 12.42% 12.57% 12.58% 291st 10/21/2009 21,940.45 12.44% 12.59% 12.61% 292nd 11/4/2009 20,788.11 12.43% 12.55% 12.52% 293rd 11/18/2009 24,871.09 12.29% 12.32% 12.19% 294th 12/2/2009 14,601.76 12.14% 12.15% 12.09% 295th 12/16/2009 26,138.09 12.14% 12.22% 12.19% 296th 12/30/2009 15,954.30 12.06% 12.10% 12.09% 297th 1/13/2010 58,720.82 11.92% 12.03% 12.02% 298th 1/27/2010 29,852.61 11.87% 11.90% 11.98% 299th 2/10/2010 61,780.54 11.92% 12.02% 12.05% 300th 2/24/2010 108,618.66 12.17% 12.22% 12.27% 301st 3/10/2010 85,850.73 12.18% 12.30% 12.36% 302nd 3/24/2010 87,547.46 12.20% 12.34% 12.36% 303rd 4/7/2010 71,435.99 12.09% 12.24% 12.30% 304th 4/21/2010 84,065.07 12.14% 12.27% 12.34% 305th 5/5/2010 80,868.51 11.96% 12.13% 12.21% 306th 5/19/2010 77,146.93 11.88% 12.09% 12.17% 307th 6/2/2010 94,147.89 11.99% 12.17% 12.30% 308th 6/16/2010 121,821.02 12.06% 12.27% 12.38% 309th 7/14/2010 109,716.23 12.09% 12.32% 12.44% 310th 7/28/2010 125,137.18 12.08% 12.33% 12.45% 311th 8/11/2010 118,519.14 12.45% 12.65% 12.78% 312th 8/26/2010 91,556.98 12.51% 12.65% 12.78% 313th 9/9/2010 81,176.34 12.55% 12.69% 12.79% 314th 9/23/2010 60,752.48 12.69% 12.82% 315th 10/6/2010 90,255.92 12.83% 13.07% 13.22% 316th 10/20/2010 127,822.74 12.77% 13.08% 317th 11/3/2010 159,140.03 12.75% 13.11% 13.24% 318th 11/15/2010 56,752.85 12.81% 13.18% 13.30% 319th 12/1/2010 125,597.80 13.10% 13.37% 13.65% 320th 12/15/2010 121,351.43 13.17% 13.39% 13.69% 321st 12/29/2010 96,519.20 13.20% 13.41% 13.73% 322nd 1/12/2011 166,201.41 13.37% 13.50% 323rd 1/26/2011 196,898.43 13.57% 13.62% 13.87% 324th 2/9/2011 169,904.85 13.52% 13.66% 13.83% 325th 2/23/2011 158,970.32 13.44% 13.68% 13.85% 326th 3/9/2011 177,824.33 13.39% 13.65% 13.84% 327th 3/22/2011 172,557.27 13.25% 13.61% 13.77% 328th 4/6/2011 209,925.86 13.25% 13.66% 13.83% 329th 4/20/2011 239,577.35 13.25% 13.61% 13.83% 330th 5/4/2011 264,157.31 13.06% 13.45% 13.78% 331st 5/18/2011 171,930.44 13.15% 13.54% 13.82% 332nd 6/1/2011 138,856.55 13.43% 13.68% 13.88% 333rd 6/15/2011 181,611.20 13.47% 13.71% 13.88% 334th 6/29/2011 72,755.64 13.46% 13.73% 13.90% 335th 7/13/2011 115,896.41 13.48% 13.74% 13.90% 336th 7/27/2011 126,149.89 13.52% 13.76% 13.91% 337th 8/10/2011 182,830.51 13.04% 13.25% 13.35% 338th 8/25/2011 114,025.56 13.03% 13.28% 13.34% 339th 9/7/2011 160,233.71 13.04% 13.26% 13.37% 340th 9/21/2011 151,390.00 13.04% 13.20% 13.29% 341st 10/5/2011 182,154.33 12.69% 12.74% 12.81% 342nd 10/19/2011 121,359.99 11.87% 11.90% 11.93% 343rd 11/2/2011 292,977.95 11.78% 11.79% 11.85% 344th 11/16/2011 126,705.31 11.78% 11.80% 11.87% 345th 11/30/2011 113,262.98 11.65% 11.67% 11.78% 346th 12/14/2011 347th 12/28/2011 3,543.49 11.83% 11.90% 348th 1/11/2012 107,264.62 11.78% 11.78% 11.89% 349th 1/25/2012 120,311.47 11.56% 11.63% 11.69% 350th 2/8/2012 158,132.48 11.71% 11.77% 11.84% 351st 2/22/2012 13,349.03 11.74% 11.81% 352nd 3/7/2012 125,196.20 11.80% 11.87% 11.92% 353rd 3/21/2012 71,060.57 11.86% 11.93% 11.94% 354th 4/4/2012 151,759.31 11.87% 11.93% 11.94% 355th 4/18/2012 164,602.00 11.87% 11.94% 356th 5/2/2012 172,604.79 11.87% 11.94% 357th 5/16/2012 159,422.53 11.87% 11.94% 11.95% 358th 5/30/2012 118,081.58 11.87% 11.94% 359th 6/13/2012 69,159.00 11.90% 11.94% 11.95% 360th 6/27/2012 99,649.00 11.92% 11.94% 11.95% 361st 7/11/2012 308,151.26 11.87% 11.92% 11.93% 362nd 7/25/2012 365,238.01 11.82% 11.84% 11.85% 363rd 8/8/2012 355,563.12 11.44% 11.49% 11.59% 364th 8/17/2012 147,839.32 10.41% 10.43% 10.46% 365th 9/5/2012 302,341.09 10.26% 10.28% 10.29% 366th 9/19/2012 284,393.79 10.23% 10.23% 10.23% 367th 10/3/2012 191,626.12 9.73% 9.74% 9.73% 368th 10/17/2012 192,649.12 9.64% 9.65% 9.69% 369th 10/31/2012 305,161.99 9.23% 9.23% 9.28% 370th 11/14/2012 151,824.56 9.24% 9.26% 9.34% 371st 11/28/2012 165,621.85 9.28% 9.32% 9.38% 372nd 12/12/2012 151,824.56 9.28% 9.28% 9.36% 373rd 12/26/2012 374th 1/9/2013 224,087.93 9.18% 9.19% 9.28% 375th 1/23/2013 324,496.47 9.09% 9.14% 9.24% 376th 2/6/2013 233,071.29 9.09% 9.15% 9.24% 377th 2/20/2013 103,811.35 9.21% 9.34% 9.37% 378th 3/6/2013 146,023.93 9.29% 9.40% 9.41% 379th 3/20/2013 131,035.44 9.38% 9.42% 380th 4/3/2013 163,222.93 9.40% 9.41% 9.44% 381st 4/17/2013 39,628.74 9.41% 9.43% 382nd 4/30/2013 168,625.58 9.43% 9.43% 9.43% 383rd 5/15/2013 261,575.59 9.40% 9.41% 9.41% 384th 5/29/2013 261,653.07 9.36% 9.33% 9.34% 385th 6/12/2013 224,513.56 9.23% 9.23% 9.21% 386th 6/26/2013 153,426.57 8.93% 8.92% 8.96% 387th 7/10/2013 240,325.29 8.89% 8.94% 8.96% 388th 7/24/2013 275,516.25 8.95% 8.96% 8.97% 389th 8/6/2013 195,712.53 8.95% 8.98% 390th 8/21/2013 33,082.81 8.96% 8.99% 391st 9/4/2013 88,293.25 8.96% 392nd 9/18/2013 515,937.91 9.35% 9.45% 393rd 10/2/2013 342,103.25 9.40% 9.45% 394th 10/14/2013 130,764.72 9.42% 395th 10/30/2013 350,174.47 9.41% 9.46% 396th 11/13/2013 64,896.16 9.43% 9.46% 397th 11/27/2013 546,352.22 9.83% 398th 12/11/2013 519,558.66 9.88% 9.98% 399th 12/24/2013 393,233.76 9.90% 9.98% 400th 1/8/2014 95,002.18 9.94% 9.95% 9.99% 401st 1/22/2014 730,802.43 9.92% 9.98% 9.99% 402nd 2/4/2014 32,408.69 9.97% 9.98% 9.99% 403rd 2/19/2014 332,680.98 9.95% 9.98% 404th 3/5/2014 284,578.72 9.96% 9.98% 9.99% 405th 3/19/2014 243,271.45 9.96% 9.98% 9.98% 406th 4/2/2014 35,176.18 9.96% 9.98% 9.99% 407th 4/16/2014 281,988.21 9.96% 9.98% 9.99% 408th 4/30/2014 331,426.34 9.94% 9.97% 9.99% 409th 5/14/2014 360,476.26 9.96% 9.97% 9.99% 410th 5/28/2014 83,262.76 9.96% 9.98% 411th 6/11/2014 92,442.76 9.96% 9.98% 9.99% 412th 6/25/2014 42,949.85 9.96% 9.97% 9.99% 413th 7/9/2014 141,029.59 9.96% 9.98% 9.99% 414th 7/23/2014 123,714.48 9.96% 9.98% 9.99% 415th 8/6/2014 92,910.08 9.96% 9.97% 9.99% 416th 8/20/2014 77,214.50 9.96% 9.98% 9.99% 417 9/3/2014 196266.929 9.96% 9.98% 9.99% 418 9/17/2014 9411.497 9.96% 9.98% 9.99% 419 10/2/2014 41950.658 9.97% 9.98% 9.99% 420 10/15/2014 121437.914 9.96% 9.98% 9.99% 421 10/29/2014 195088.301 9.96% 9.95% 9.98% 422 11/12/2014 302425.556 9.93% 9.92% 9.96% 423 11/26/2014 190559.725 9.45% 9.47% 9.48% 424 12/10/2014 73795.611 9.46% 9.49% 9.49% 425 12/24/2014 50152.228 9.48% 9.47% 9.42% 426 1/7/2015 222022.15 9.07% 9.13% 9.10% 427 1/21/2015 175586.389 8.92% 8.96% 8.64% 428 2/4/2015 192528.697 8.34% 8.39% 8.34% 429 2/18/2015 109237.517 8.32% 8.34% 8.28% 430 3/4/2015 94758.488 8.18% 8.12% 7.98% 431 3/18/2015 249835.795 8.16% 7.89% 7.77% 432 4/1/2015 83088.273 7.96% 7.93% 7.84% 433 4/15/2015 163371.545 7.92% 7.84% 7.75% 434 4/29/2015 251400.211 7.38% 7.26% 7.17% 435 5/13/2015 109270.849 6.86% 6.72% 6.77% 436 5/27/2015 102196.194 6.61% 6.64% 6.72% 437 6/10/2015 74174.603 6.74% 6.75% 6.78% 438 6/24/2015 93356.076 6.86% 6.94% 6.97% 439 7/8/2015 111660.639 6.93% 6.95% 6.97% 440 7/22/2015 219900.886 6.92% 6.95% 6.94% 441 8/5/2015 354999.594 6.92% 6.92% 6.93% 442 8/19/2015 236486.905 6.93% 6.95% 6.95% 443 9/2/2015 196421.301 6.93% 6.95% 6.97% 444 9/16/2015 147537.751 6.46% 6.45% 445 9/30/2015 58861.994 6.47% 6.48% 446 10/14/2015 177754.57 6.44% 6.47% 6.47% 447 10/28/2015 223051.067 6.30% 6.30% 6.31% 448 11/11/2015 262844.615 6.26% 6.28% 6.29% 449 11/25/2015 138925.026 6.37% 6.38% 450 12/9/2015 92386.556 6.38% 6.39% 451 12/23/2015 30393.361 6.34% 6.36% 6.39% 452 1/6/2016 246064.088 6.30% 6.28% 6.28% 453 1/20/2016 316374.633 6.16% 6.17% 6.17% 454 2/3/2016 330490.656 6.25% 6.24% 6.22% 455 2/17/2016 196591.968 6.21% 6.22% 6.22% 456 3/2/2016 184986.521 6.17% 6.19% 6.20% 457 3/16/2016 223278.825 6.15% 6.20% 6.21% 458 3/30/2016 56397.282 6.17% 6.18% 6.20% 459 4/13/2016 66721.213 6.17% 6.17% 6.21% 460 4/27/2016 461 5/11/2016 245679.052 6.20% 6.24% 6.25% 462 5/25/2016 278103.844 5.99% 6.00% 6.02% 463 6/8/2016 139185.129 5.95% 5.96% 6.00% 464 6/22/2016 193110.955 5.90% 5.89% 5.91% 465 7/4/2016 218245.065 5.87% 5.89% 5.91% 466 7/20/2016 424360.814 5.79% 5.82% 5.84% 467 8/3/2016 378348.707 5.85% 5.89% 5.90% 468 8/17/2016 386601.458 5.86% 5.90% 5.91% 469 8/31/2016 179097.296 5.86% 5.90% 5.91% 470 9/9/2016 85898.684 5.86% 5.90% 5.91% 471 9/28/2016 34308.28 5.86% 5.90% 5.91% 472 10/10/2016 72547.472 5.86% 5.90% 5.91% 473 10/26/2016 97514.684 5.88% 5.90% 5.91% 473rd 10/26/2016 97,514.68 5.88% 5.90% 5.91% 474th 11/9/2016 306,282.09 5.92% 5.92% Bids Rejected 475th 11/23/2016 296,659.92 5.95% 5.94% 5.95% 476th 12/7/2016 154,838.47 5.95% 5.95% Bids Rejected 477th 12/21/2016 152,202.24 5.96% 5.98% Bids Rejected 478th 1/4/2017 256,025.10 5.96% 5.98% 5.99% 479th 1/18/2017 538,376.80 5.88% 5.90% 5.93% 480th 2/1/2017 606,392.13 5.92% 5.97% 5.95% 481st 2/15/2017 640,235.80 5.94% 5.99% 5.99% 482nd 3/1/2017 397,079.46 5.95% 5.99% 5.99% 483rd 3/15/2017 286,640.28 5.95% 5.99% Bids Rejected 484th 3/29/2017 162,456.36 5.97% 5.99% No Bids Received 485th 4/12/2017 267,163.99 5.98% Bids Rejected Bids Rejected 486th 4/26/2017 376,024.81 5.99% 6.01% 6.00% 487th 5/10/2017 371,684.48 5.99% 6.01% 6.03% 488th 5/24/2017 341,492.97 5.99% 6.01% 6.05% 489th 6/7/2017 160,796.06 5.99% 6.01% 6.05% 490th 6/21/2017 354,774.75 5.99% 6.01% 6.04% 491st 7/5/2017 544,940.31 5.99% 6.01% 6.04% 492nd 7/19/2017 1,071,255.38 5.99% 6.01% 6.04% 493rd 8/2/2017 733,603.49 5.99% 6.01% 6.04% 494th 8/16/2017 615,802.41 5.99% 6.01% Bids Rejected 495th 8/31/2017 520,572.10 5.99% 6.01% 6.04% 496th 9/13/2017 371,820.49 5.99% 6.01% 6.04%

## List of KSE-100 Companies September 2017

Category:Uncategorized

 Name Market Capitalization Percentage in the Index Habib BankXD 140,935,188,968.64 6.49% Oil & Gas Dev. 97,945,042,453.20 4.51% United Bank 93,160,074,218.75 4.29% Engro CorpXD 92,586,550,244.85 4.27% Pak Petroleum 86,175,312,235.56 3.97% MCB Bank LtdXD 83,190,700,725.10 3.83% Hub Power Co. 80,475,458,975.12 3.71% Lucky CementXD 77,564,727,500.00 3.57% Nestle PakistanXD 58,954,454,000.00 2.72% Fauji Fert.XD 57,293,977,227.68 2.64% P.S.O. 55,313,490,972.96 2.55% Pak Oilfields 54,088,098,970.50 2.49% Sui North Gas 48,592,919,041.04 2.24% Bank AL-Habib 42,550,922,028.00 1.96% Dawood Hercules 41,428,713,633.57 1.91% Engro Fert.XD 37,681,480,728.49 1.74% D.G.K.Cement 36,833,988,622.90 1.70% Kot Addu Power 35,049,251,958.87 1.62% Mari PetroleumXD 34,364,704,500.00 1.58% Meezan Bank 30,884,327,166.00 1.42% National Bank 30,464,187,028.60 1.40% Millat Tractors 27,667,116,146.88 1.27% Fauji Cement 26,394,481,621.92 1.22% Nishat Mills Ltd 26,215,284,666.88 1.21% The Searle Co. 24,094,564,396.20 1.11% Bank Al-Falah 23,389,368,439.87 1.08% Indus Motor Co 23,266,715,860.16 1.07% Inter.Steel LtdXD 22,449,480,000.00 1.03% Pak Services 22,014,798,020.00 1.01% Maple LeafXR 20,772,398,954.49 0.96% Kohinoor Textile 19,054,737,162.78 0.88% TRG Pak Ltd 18,895,604,969.40 0.87% Pak ElektronXD 18,869,593,541.69 0.87% Packages Ltd. 18,818,183,980.30 0.87% Thal Limited 18,450,509,937.75 0.85% Pak Tobacco 17,989,053,800.00 0.83% K-Electric Ltd. 17,425,187,571.75 0.80% Pak Int.Bulk 17,057,003,938.15 0.79% National Refinery 16,669,308,874.72 0.77% Abbott Lab.XD 16,651,150,683.10 0.77% Adamjee Ins. 16,193,625,000.00 0.75% Habib Metropol. 15,932,801,569.14 0.73% Allied Bank Ltd. 15,626,822,603.50 0.72% Honda Atlas Cars 15,532,070,400.00 0.72% Attock Refinery 14,528,127,276.00 0.67% Cherat Cement 13,674,484,821.36 0.63% Attock Petroleum 12,974,929,920.00 0.60% Fatima Fert. 12,940,200,000.00 0.60% ICI PakistanXD 12,548,131,883.50 0.58% Sui South Gas 12,523,213,370.68 0.58% Fauji Fert BinXD 12,214,422,360.00 0.56% Hascol PetrolXD 12,143,344,500.00 0.56% Pioneer Cement 11,578,682,560.48 0.53% B.O.Punjab 11,109,548,100.96 0.51% EFU General 10,990,000,000.00 0.51% Colgate PalmoliveXD 10,568,067,698.75 0.49% Pak Suzuki 9,489,628,223.76 0.44% IGI Insurance 9,487,888,233.39 0.44% GlaxoSmithKline 9,249,930,178.80 0.43% National Foods 9,194,590,435.72 0.42% Philip Morris Pak. 9,103,637,193.39 0.42% Faysal Bank 9,098,260,742.34 0.42% Shell PakistanXD 8,771,372,640.78 0.40% Murree Brewery 8,750,293,397.01 0.40% Jubile Life InsXD 8,317,821,798.00 0.38% P.T.C.L. 8,302,227,634.67 0.38% PICIC GrowthXD 7,647,215,736.60 0.35% Engro Foods Ltd. 7,582,401,827.28 0.35% J.D.W.Sugar 7,533,951,343.10 0.35% Askari Bank 7,527,534,055.14 0.35% Shifa Int.Hosp 7,510,141,519.50 0.35% Nishat ChunPow 7,414,420,454.70 0.34% Kohat Cement 7,395,558,446.85 0.34% Nishat Power 7,261,115,825.25 0.33% Jah.Sidd. Co. 6,666,228,690.16 0.31% Crescent Steel 6,398,469,990.64 0.29% Nishat (Chun.) 6,245,760,456.00 0.29% Hum Network 6,118,875,000.00 0.28% Dolmen City XD 6,076,260,250.00 0.28% Saif Power Ltd.XD 5,945,068,867.14 0.27% Pak.Int.Cont.XD 5,403,081,090.00 0.25% Ghani Glass Ltd 5,333,208,642.50 0.25% Bata (Pak) 5,282,387,350.14 0.24% Bestway Cement 5,187,399,186.00 0.24% Soneri Bank Ltd 4,630,346,616.00 0.21% St.Chart.BankXD 4,552,983,983.52 0.21% Attock Cement 4,503,710,655.22 0.21% Jubilee Gen.Ins 4,055,536,795.60 0.19% Cherat PackXR 3,846,983,078.25 0.18% Service Ind.LtdXD 3,810,160,880.76 0.18% Arif Habib Corp 3,408,570,000.00 0.16% Ferozsons (Lab) 2,934,221,221.68 0.14% Orix Leasing 1,681,876,449.06 0.08% Indus Dyeing 1,428,728,620.00 0.07% Feroze 1888 1,426,003,233.12 0.07% Ibrahim Fibres 1,117,825,200.00 0.05% Allied Rent. 987,187,500.00 0.05% Punjab Oil 447,920,267.04 0.02% Bannu Woollen 263,128,277.63 0.01% Crescent Jute 30,833,099.73 0.00%

## Research Topics in Finance – Corporate Governance

Category:Uncategorized

Green governance and sustainability reporting in industries that are more likely to pollute e.g, oil, mining, gas etc

Do better governed firms generate more green patents? Can institutional ownership play a role?

Do Investors and creditors price firms social and governance risks?

Are family firms more concerned about governance of the firm?

How green growth is possible for developing countries?

## Rolling window regressions in Stata

Category:Blog

Rolling window statistics are also known as sliding or moving window statistics. Rolling window regressions have special use in Finance and other disciplines. Rolling window calculations require lots of looping over observations. The problem is compounded by different data structures such as unbalanced panel data, data with many duplicates, and data with many missing values. Yet, there might be data sets that have both time series gaps as well as many duplicate observations across groups.

## asreg : A simple and fast solution to rolling window regressions

asreg is a Stata program for estimation of rolling window regressions. To estimate rolling window regressions in Stata, the conventional method is to use the rolling command of Stata. However, that command is too slow, especially for larger data set. asreg is order of magnitude faster than estimating rolling window regressions through conventional methods such as Stata loops or using the Stata’s official rolling command. asreg has the same speed efficiency as asrol. All the rolling window calculations, estimation of regression parameters, and writing the results to Stata variables are done in the Mata language.

## Why asreg is so fast?

Rolling window calculations require lots of looping over observations. The problem is compounded by different data structures such as unbalanced panel data, data with many duplicates, and data with many missing values. Yet, there might be datasets that have both time series gaps as well as many duplicate observations across groups. asreg does not use a static code for all types of data structures. Instead, asreg intelligently identifies data structures and matches one of its rolling window routines with the data characteristics. Therefore, the rolling window regressions are fast even in larger data sets. asreg writes all regression outputs to the data in memory as separate variables. This eliminates the need for writing the results to a separate file and then merging them back to the data for any further calculations.

### Installation

asreg can be installed for free by typing the following command in the Stata’s command window:

ssc install asreg

After the installation is complete, we can directly use asreg from the Stata’s command window. Let us use the grunfeld data set from the web and estimate rolling regressions with asreg. To download the dataset, type the following from the Stata command window:

webuse grunfeld, clear

Please note that the word clear after comma tells Stata to unload an existing data set from its memory. So this option has to be used carefully as this might result in losing any unsaved changes to the data set in memory.

#### Example 1: regression in a 10-years rolling window

bys company: asreg invest mvalue kstock, wind(year 10)

Explanation: Let us discuss the components of the code line that we used above for 10-years rolling regressions.

bys company : forces asreg to estimate the rolling regression separately for each company

asreg invest mvlaue kstock : asreg invokes the asreg program. Right after asreg, we have to type the name of the dependent variable, and then the full list of independent variables. Therefore, in our example, the dependent variable is invest, and we have two independent variables, i.e., mvalue and kstock.

, wind(year 10) : After the comma, the program’s optional options are specified. The phrase wind(year 10) tells Stata to use a rolling window of 10 observation, based on the values of the existing variable year.

#### Example 2: Regression for each company in a recursive window

webuse grunfeld

bys company: asreg invest mvalue kstock, wind(year 10) rec

OR

. bys company: asreg invest mvalue kstock, wind(year 1000)

#### Example 3: Using option minimum

. webuse grunfeld

. bys company: asreg invest mvalue kstock, wind(year 10) min(5)

#### Example 4: Reporting standard errors

. webuse grunfeld

. bys company: asreg invest mvalue kstock, wind(year 10) se

#### Example 5: Reporting standard errors, fitted values and residuals

. webuse grunfeld

. bys company: asreg invest mvalue kstock, wind(year 10) se fit

#### Example 6: Reporting Newey-West standard errors with two lags

. webuse grunfeld

. bys company: asreg invest mvalue kstock, wind(year 10) newey(2)