Hi,

I would like to export summary statistics (two sample t-test of the difference of the two groups, as well as mean and sd by groups) using asdoc for a number of variables (lnassets roi lev cagr vol cfvol lncash delist), based on the dummy variable BClaw. BClaw is equal to 1 if the state that firm (gvkey) is incorporated in (incorpn) has passed a certain law. Here is an example of my data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long(gvkey incorpn datadate) float(BClaw lnassets roi lev cagr vol cfvol lncash delist)
1003  9  8400 1   1.7284646    .1649503  .2224787          .         .          .   -1.1615521 0
1003  9  8765 1   2.1434722    .1231094 .14069645          .         .          .     .7045816 0
1003  9  9131 1   2.1091218   .04696032 .11527728          .  .3243487   .1695239   -1.3205066 0
1003  9  9527 1    2.638343  .016869193 .33595425  35.431084 .22307177          .    -5.298317 0
1003  9  9892 1    2.680062    .0543672  .2579871   19.58573 .13903955  .05188768   -1.4229584 0
1003  9 10257 1   2.7752104  .011594565  .3433487  24.860825  .3012686  .06689375    -.7444405 0
1003  9 10623 1    2.789937   -.4814496  .4748157   5.183002 .25959867  .11679138   -1.1973282 1
1003  9 10988 1    2.313426  -.02186171  .4476209 -11.503928         .          .            . 0
1004  9  6360 1    3.818811   .03953897  .4840834          .   .447139          .     .6941467 0
1004  9  6725 1    4.034276  .035662454   .474585          .  .3880906          .     .9764447 0
1004  9  7090 1   4.1619096   .04681123  .4885971          .  .4276877          .     .9321641 0
1004  9  7456 1   4.3007894   .05044876 .46216005  17.428518  .4554453          .    1.1226543 0
1004  9  7821 1    4.419744   .04340656   .467108   13.71092  .4464859          .    1.1098819 0
1004  9  8186 1     4.73315  .010778422  .3832191   20.97496  .4508259  .14559905     .5590442 0
1004  9  8551 1   4.7121215  .025115017  .3120642  14.695506 .43949175  .03337184 -.0020020027 0
1004  9  8917 1    4.921644   .03269741 .11526802  18.210882  .2905666  .01543511    .18481843 0
1004  9  9282 1    5.046035   .05837006 .18887423   10.99277  .2757429  .04981864     .8006554 0
1004  9  9647 1    5.289715     .058027  .2869578   21.23145  .3445867  .07587934    1.2610146 0
1004  9 10012 1    5.459973   .06534065 .20540556  19.655066  .3224897 .033278447      .958967 0
1004  9 10378 1    5.652307   .07451535  .2549553    22.3959  .4922575  .06017629            . 0
1004  9 10743 1    5.876029   .06962577 .26930535    21.5843  .2821075 .005485314    1.5184186 0
1004  9 11108 1    5.962347   .06603247  .2732156  18.229586  .3325457  .01752719    1.3972343 0
1004  9 11473 1    5.940061   .03895431 .22490117   10.06688  .5263988  .04419932     .4401886 0
1004  9 11839 1    5.979774   .02534457 .23353425   3.518675  .3404748  .02192023     .8109302 0
1004  9 12204 1    5.900311 .0007750219 .25009653 -2.0466413 .28526157  .01651055       .81315 0
1004  9 12569 1    6.034586   .02273326 .27847165  3.2010174 .22665544 .035685968    2.8944745 0
1004  9 12934 1    6.054003   .02457176 .28509632   2.505153  .2345718  .03266471    3.1129375 0
1004  9 13300 1    6.081867  .036569934 .27353454   6.238753 .27757648 .015314956     3.514705 0
1004  9 13665 1    6.272092   .04347752  .2233678   8.238668  .3334143 .005712112    3.9455545 0
1004  9 14030 1    6.508111   .05317504  .2650714  16.342669   .199219  .04456652    2.8461876 0
1004  9 14395 1    6.588418   .05734831  .2495892   18.39426  .4494495 .011976158    2.1102133 0
1004  9 14761 1    6.607998   .04745357 .27903044  11.847786   .534973  .02221332     .2159175 0
1004  9 15126 1    6.553725   .02640293  .2758964  1.5320748  .5737165   .0482364    2.6253204 0
1004  9 15491 1    6.565545  -.08298942    .36641  -.7595075  .4977813  .06240025     3.541597 0
1004  9 15856 1    6.531783 -.018074017  .3741715  -2.508516   .780392  .02444072     3.372592 0
1004  9 16222 1    6.564267  .004940137  .3553656   .3520143  .5960131          .     3.713816 0
1004  9 16587 1    6.596095  .021104025  .3153435  1.0235178 .42082205 .018312065    3.7014995 0
1004  9 16952 1    6.886347  .035923906  .3278083  12.545578  .3538446 .027473735     4.801871 0
1008  6  8917 0    .4317824   -.5746753 .05714286          .  .5316426   .7218414   -2.0402207 0
1008  6  9282 0 -.027371196  -.55806786  .1839671          . .45749855 .005388222   -1.5232602 0
1008  6  9647 0  -.03562718    -.822798 .03626943          .  .7069297   .1002469   -1.1394343 0
1009  9  7974 1   3.4354055  -.20596573  .5390736          .         .          .   -1.1647521 0
1009  9  8339 1    3.246063   -.2466036  .6598155          .  .2062948          .    -1.214023 0
1009  9  8704 1    2.089392   -.3690594  .8872524          . .54315466   .1629517   -1.4481697 0
1009  9  9070 1    2.182562   .24873154  .7358214 -34.138393  .3064029 .072737806   -1.0216513 0
1009  9  9435 1   2.3560312    .2854299  .5620438 -25.671616  .3166397  .05993561   -2.5383074 0
1009  9  9800 1    2.650421   .18368644  .6327683    20.5639  .4450549  .06218425   -1.3823023 0
1009  9 10165 1    2.853247   .06688192  .6534248   25.05226  .4495864  .04535501    -6.214608 0
1009  9 10531 1     2.78606   .09280385  .4867115   15.41256  .9953872 .024326267    -.9493306 0
1009  9 10896 1    3.261514   .07528077   .633677  22.592733  .5440766 .030183265    -3.912023 0
1009  9 11261 1     3.47615   .06602752   .648647   23.07633  .6286498 .021390636    -6.214608 0
1009  9 11626 1    3.571193  .030484546  .5955454  29.915113  .6767214  .01319791    -3.036554 0
1009  9 11992 1    3.737098   .05688965 .51465124  17.178484  .5621175  .04781688   -2.4769385 0
1009  9 12357 1   4.1588364   .05253371  .5911996   25.55353  .6286818  .02405528    -.6674795 0
1009  9 12722 1    4.541282   .05175299  .6292439   38.17668  .4745038 .012205282    -1.838851 0
1010 32  6209 1    6.587965   .04684972  .3442347          .  .2205974  .02286955     2.329519 0
1010 32  6574 1    6.670539    .0455249  .3435811          .    .19338 .009634356    2.3657477 0
1010 32  6939 1    6.830786   .04450718  .3647299          . .22305876 .015862195     2.409644 0
1010 32  7304 1    6.924412   .04705074  .3582557  11.867963  .2194916 .022876967    2.4697084 0
1010 32  7670 1    7.011654   .04033933  .3607069  12.042136  .3019638 .014513645    2.3791757 0
1010 32  8035 1    7.123317   .03830934  .3727295   10.24231 .21827044          .     2.485906 0
1010 32  8400 1      7.0902  .027559934  .3910101    5.68183 .27717042 .015707677    2.5732226 0
1010 32  8765 1    7.067373 .0015736594   .375305  1.8746475  .3048166 .009196619     2.674631 0
1010 32  9131 1    7.059311  .027731873   .748532 -2.1109502         .   .0995543    2.6055005 0
1010 32  9496 1    7.301307  .021279337  .7404664   7.290397         .  .04167838     2.710647 0
1010 32  9861 1    7.306142 -.006740879  .7721482   8.284278         .  .04845259     .7011154 0
1010 32 10226 1    7.579686   .00269661  .6050774  18.941116         .  .15194876    2.8202474 0
1010 32 10592 1    7.595028  .007575373   .623316   10.28601         .   .0235544     3.387166 0
1010 32 10957 1     7.49831   .15727852  .6786623     6.6152         .  .19623864     6.025946 0
1010 32 11322 1    7.455234  -.04354649  .6556966   -4.06354         . .018232454     3.346495 0
1010 32 11687 1    7.470943   .08937106  .6549438 -4.0517874         .  .02663246     5.003248 0
1010 32 12053 1    7.442173 -.010436848  .6046861 -1.8538333         .  .03513778     4.384436 0
1010 32 12418 1    7.418133   .06737955  .4544579 -1.2290614         . .032858614     2.492048 0
1010 32 12783 1    7.503896  .013883533  .4523167  1.1044841         . .016176423    4.0707345 0
1010 32 13148 1    7.608771   .04181962 .50932634   5.710376         .          .            . 0
1010 32 13514 1    7.704632   .04164788  .4888669  10.020818         .          .            . 0
1010 32 13879 1    8.065045  .068022504 .56775534   20.56873         .          .            . 0
1010 32 14244 1    8.088654  .020630583  .5540171   17.34649         .          .            . 0
1010 32 14609 1    8.178471  .021692766 .55483526  17.110325         .          .            . 0
1010 32 14975 1    8.241308  .021056794  .5383845   6.051458         .          .            . 0
1010 32 15340 1    8.222312   .03913406  .5118047   4.556005         .          .            . 0
1010 32 15705 1   8.2167635  .021525996 .53172183  1.2846186         .          .            . 0
1010 32 16070 1    8.483036   .07294965  .3849465    8.39114         .          .     6.477895 0
1011 39  8400 1   1.3373667   .06957207 .51509583          .         .          .   -4.2686977 0
1011 39  8765 1   1.5452193  .007037748 .21603754          .  .5762995 .027964767    -2.688248 0
1011 39  9131 1    1.771897  .011050663  .3356001          .  .6184222          .   -1.8773173 0
1011 39  9496 1   1.9516082   .01377841 .40823865  22.721474  .6657602 .004830414   -1.0613165 0
1011 39  9861 1   1.8721098   -.1045832 .20609044  11.512164  .7673731  .03094232    -.3797974 0
1011 39 10226 1   1.6164135  -.25878847 .28500497  -5.050762  .7141827  .04586212   -3.3242364 0
1011 39 10592 1   1.6058314   .06061823 .22581293  -10.88646 .56852126 .009239657    -2.918771 0
1011 39 10957 1    2.025645  -.10394407  .5140483   5.251068   .518975  .04730276   -1.7037486 0
1011 39 11322 1   2.0520704   -.2401079  .7569373   15.62927  .6399881  .02649085   -1.7660917 0
1011 39 11687 1   2.1656191  -.16605504  .7097477  20.514025   .672135  .04844726     .2021242 0
1011 39 12053 1    2.837498  -.12610555  .3663679   31.07739         .  .04555298    2.1559396 0
1011 39 12418 1   3.2180755  -.12642114   .336229   47.50153  .6990436 .021032084   -.04814038 0
1011 39 12783 1   4.2090416  -.13668787 .17080782   97.61306  .7365833 .036273457     .5816568 0
1012 40  6148 0   1.6646833   .09102952 .05809993          .         .          .   -4.2686977 0
1012 40  6513 0   1.8017098   .11485148 .06815182          .         .          .    -5.809143 0
1012 40  6878 0   2.1049874   .07980992 .15401487          .  .6825735          .   -2.8824036 0
1012 40  7243 0   2.0775647 -.065122105 .20338134   14.75476  .6335995          .    -2.703063 0
end
format %d datadate
label values incorpn incorpn
label def incorpn 6 "CA", modify
label def incorpn 9 "DE", modify
label def incorpn 32 "NJ", modify
label def incorpn 39 "PA", modify
label def incorpn 40 "RI", modify
The code I have been trying it with looks as follows:
Code:
asdoc ttest lnassets, by(BClaw) label stat(mean sd dif) save(sumtable.doc)
asdoc ttest roi, by(BClaw) rowappend label stat(mean sd dif) 
asdoc ttest lev, by(BClaw) rowappend label stat(mean sd dif) 
asdoc ttest cagr, by(BClaw) rowappend label stat(mean sd dif) 
asdoc ttest vol, by(BClaw) rowappend label stat(mean sd dif) 
asdoc ttest cfvol, by(BClaw) rowappend label stat(mean sd dif) 
asdoc ttest lncash, by(BClaw) rowappend label stat(mean sd dif) 
asdoc ttest delist, by(BClaw) rowappend label stat(mean sd dif)
which returns the error message:
asdoctable(): 3301 subscript invalid
<istmt>: - function returned error
r(3301);
if I simply do
Code:
asdoc ttest lnassets, by(BClaw)
it seems to work but the output contains a lot more information than I want.
Ideally I would do the above with a loop, and if possible clustering the s.e.'s around incorpn, as such:
Code:
foreach i in lnassets roi lev cagr vol cfvol lncash delist{
asdoc ttest `i', by(BClaw) rowappend label stat(mean sd dif) 
}
But I would be happy if I could get the first version to work. Any help would be appreciated!

Thanks