Hello Members

I had been working on EViews for some time, I shifted to Stata now, since I am new, I have been trying to calculate T and Wilcoxon Tests of Difference (of two variables).
I have 24 different variables. VarA VarB VarC VarD and Var1 to Var20. Though these are not the original names of those 24 variables I need to calculate these tests for.
I have huge number of observations, 19393 to be precise. These are firm-year observations.
I have two variable sets
VarA to varD
Var1 to Var20



I need to calculate T and Wilcoxon tests in this way:

ttest VarA = Var1
ttest VarB = Var2
ttest VarC= Var3
ttest VarD = Var4

ttest VarA = Var5
ttest VarB = Var6
ttest VarC = Var7
ttest VarD = Var8

ttest VarA = Var9
ttest VarB = Var10
ttest VarC = Var11
ttest VarD = Var12

ttest VarA = Var13
ttest VarB = Var14
ttest VarC = Var15
ttest VarD = Var16

ttest VarA = Var17
ttest VarB = Var18
ttest VarC = Var19
ttest VarD = Var20

I need to do it for both tests and it will take a lot of time to do for both tests. And I also need to export these results to Excel or Word. The important results I need from these tests is the T and Z values, means and its differences and P value.

I am using simple command for T-Test:

ttest VarA=Var1 if sample_common==1 // for common sample
ttest VarB=Var2 if sample_common==1 // for common sample
and so on
ttest VarD=Var20 if sample_common==1


and for Wilcoxon:

signrank VarA=Var1 if sample_common==1
signrank VarB=Var2 if sample_common==1
and so on until:
signrank VarD=Var20 if sample_common==1


I did it in EViews and it took days.

Question1: Any loop to solve this for 22 tests for T Test and 22 for Wilcoxon.
Question2: I can do it manually, it shouldn't take much time in Stata anyway, but I have to export these results in Excel or Word. Is it possible to store all 44 results from T and Wilcoxon tests and export at one time instead of using "asdoc" or "estpost" commands to do it one by one.

PS: I have other names for these variables on my Stata files. but if I needed to apply loop and if I had to change the names, I would.
PS: I am posting this question second time, probably I this time I have tried to be more precise and clearer

Many thanks in advance
Qureshi Qazi


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str90 Name int Data_Year float(VarA VarB VarC VarD Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10)
"3Com Corp"                     2006   .063745834    .08969723      .069065    .09025278   .23625404   .21030265    .23093487    .2097471    .28277314    .25682175    .27745396    .25626618    .033384956    .007433569
"3Com Corp"                     2007    .16977616    .19370146     .1685596     .1953236   .21452543   .23845074    .2133089    .24007288    .1668212    .1907465    .16560467    .19236866    .04178643    .06571174
"3Com Corp"                     2008    .01767699     .0154646   .019336283   .034823008  .030258216  .028045826    .031917505    .04740423    .033407442    .03119505    .03506673    .05055346    .04746863    .04525624
"3Com Corp"                     2009    .14623202            0    .15350877            0   .14623202           0    .15350877    0    .14623202    0    .15350877    0    .14623202    0
"3D Systems Corporation"        2006      .039646 .00020166667     .0490905 .00020166667   .03763147 .0018128604    .04707598    .0018128604    .02352965    .015914686    .03297415    .015914686    .004353501    .04379784
"3D Systems Corporation"        2007  .0022994361    .00480564  .0022994361    .00480564  .009673823  .007167619    .009673823    .007167619    .0152432    .012736997    .0152432    .012736997    .024439054    .02193285
"3D Systems Corporation"        2008   .006780514  .0019229947   .006780514  .0019229947  .006426498 .0015689787    .006426498    .0015689787    .005438766    .00058124587    .005438766    .00058124587    .0339265    .02906898
"3D Systems Corporation"        2009   .013091595  .0003426961    .01351137  .0003426961   .04784323   .03440894    .04826301    .03440894    .032321885    .018887596    .032741662    .018887596    .015538788    .02897308
"3D Systems Corporation"        2010   .010408957  .0018122155   .010408957  .0015592063   .08288364    .0742869    .08288364    .074033886    .07043226    .06183552    .07043226    .06158251    .05507143    .06366817
"3D Systems Corporation"        2011  .0021587943  .0008884781 .00012632662  .0007614846  .003817905  .002547588    .0017854348    .002420593    .0023259483    .003596265    .0043584183    .00372326    .0009045005    .002174817
"3D Systems Corporation"        2012   .034877814   .036073748   .034530625   .036266666   .04522194   .04641788    .04487475    .0466108    .04598092    .04717685    .04563373    .04736977    .027396336    .028592274
"3D Systems Corporation"        2013   .014645678   .011313648     .0146691   .011295148   .02164196  .018309928    .02166538    .018291429    .02130642    .017974392    .02132984    .017955892    .0020181816    .005350212
"3D Systems Corporation"        2014   .006814484   .006349909   .006749919   .006373292    .0076736  .007209024    .007609035    .007232408    .006485644    .006021068    .006421079    .006044452    .00010808185    .0005726572
"3D Systems Corporation"        2015    .18139833     .1863056     .1819054     .1863167   .20626158   .21116886    .20676865    .21117996    .16404065    .1689479    .1645477    .168959    .14261276    .14752004
"3D Systems Corporation"        2016    .09154546    .09252198    .09154546     .0926962   .05696752   .05794405    .05696752    .05811827    .04235609    .04333261    .04235609    .04350684    .068535976    .0695125
"3D Systems Corporation"        2017     .0422009    .04366238    .04201279    .04389391   .01915851  .020619985    .0189704    .02085151    .007609781    .009071256    .00742167    .009302784    .0043729735    .005834448
"3D Systems Corporation"        2018    .04688773   .064143635    .04688773    .06424884   .05238211  .069638014    .05238211    .069743216    .030802766    .04805867    .030802766    .04816388    .04165558    .024399675
"3M Company"                    2006   .007902322   .008422193    .00789471   .008539871 .0027746186   .00329449    .002767008    .0034121685    .001578681    .0010588095    .001586292    .0009411313    .022377644    .02185777
"3M Company"                    2007   .009525856   .009252021   .009461696   .009269216  .003089823  .002815984    .0030256584    .00283318    .0018383823    .002112221    .0019025467    .002095025    .02678877    .027062606
"3M Company"                    2008   .002358515  .0021152752     .0020338   .002626779 .0036961474 .0039393865    .0040208623    .003427882    .000344336    .0005875751    .000669051    .00007607043    .03844815    .03820491
"3M Company"                    2009 .00028154327  .0021755302 .00014198819   .002291102  .000513874  .002407864    .00009034574    .002523437    .005798586    .007692575    .005375057    .007808149    .063203245    .065097235
"3M Company"                    2010 .00012979316  .0002218459 .00019729044  .0003182533  .001575403  .001667455    .0016428977    .001763858    .005023457    .005115509    .005090952    .005211912    .0443816    .04447365
"3M Company"                    2011    .00144438  .0010095017  .0016821553  .0009869061   .01167959  .012114465    .011441812    .012137063    .015261516    .015696391    .015023738    .01571899    .0389358    .03937067
"3M Company"                    2012  .0011355683  .0010253274  .0011939312  .0010324238  .001641661 .0017518997    .0015833005    .0017448068    .00642407    .006534308    .006365709    .006527215    .04044257    .04055281
"3M Company"                    2013  .0012451266   .001289607  .0012641896  .0012103393   .02736242    .0274069    .027381487    .027327634    .023072034    .023116514    .0230911    .02303725    .04288026    .04283578
"3M Company"                    2014  .0011115152  .0010260963  .0010981105  .0010268093 .0033697374 .0032843165    .00335633    .003285032    .00008535385    6.7055225e-08    .00007194653    6.482005e-07    .03796756    .03805298
"3M Company"                    2015  .0010885468  .0008731743  .0010673078  .0008847371  .007901259  .007685889    .007880021    .007697452    .004525643    .0043102726    .004504405    .004321836    .033128984    .033344354
"3M Company"                    2016   .001311073  .0013082847  .0013359665   .001269583   .00561408  .005611293    .005638976    .005572591    .0019335747    .001930788    .0019584708    .001892086    .03909488    .03909767
"3M Company"                    2017  .0020558885  .0014581957   .001880831  .0013208266  .005040143  .005637836    .005215202    .005775206    .0084559955    .0090536885    .008631054    .009191059    .02746413    .028061824
"3M Company"                    2018   .002394655  .0024441944  .0023865404   .002451757  .004556708  .004507169    .0045648217    .004499607    .0021658428    .002116304    .0021739565    .0021087416    .025048865    .025098404
"3Par Inc."                     2008  .0013813954   .001285969  .0010992248   .000324031   .05037327   .05027785    .04789265    .04866785    .04598048    .04588505    .04349986    .04427505    .01888669    .018982116
"3Par Inc."                     2009   .015931848   .020027524   .014621233   .019863695   .05308522    .0571809    .05177461    .05701707    .05260266    .05669833    .05129204    .0565345    .011556804    .01565248
"4Kids Entertainment Inc."      2006   .010503505   .004155513   .010503505   .004155513   .06159928    .0762583    .06159928    .0762583    .06085967    .0755187    .06085967    .0755187    .06401655    .07867557
"51job Inc Sponsored ADR"       2006  .0009983673  .0021634013  .0009983673  .0007284353  .014379997  .013214964    .014379997    .01464993    .007414099    .006249066    .007414099    .007684033    .0009983685    .0021634009
"51job Inc Sponsored ADR"       2007   .006390861   .004669244  .0035826596   .006235618  .001592569  .003314186    .004400771    .0017478094    .0039211884    .0021995716    .0011129864    .003765948    .00639086    .004669243
"51job Inc Sponsored ADR"       2008    .00554606   .003545061   .007244617   .003545061  .018473737  .016472738    .020172294    .016472738    .022097744    .020096745    .0237963    .020096745    .00554606    .003545061
"51job Inc Sponsored ADR"       2010   .003085282  .0045155487  .0028973166    .00542219   .02915079  .030581053    .028962824    .0314877    .04217244    .04360271    .04198448    .04450935    .003085278    .0045155436
"51job Inc Sponsored ADR"       2011 .00009827411  .0020869034 .00009827411  .0020869034   .09238305   .09437168    .09238305    .09437168    .10061754    .10260616    .10061754    .10260616    .00009827316    .002086904
"51job Inc Sponsored ADR"       2013    .03462349   .036381774    .03462349   .036592685   .06918992    .0709482    .06918992    .07115911    .07451138    .07626967    .07451138    .07648058    .03462349    .036381774
"51job Inc Sponsored ADR"       2014   .015530784    .02824252   .015530784    .02821915    .0295283    .0733016    .0295283    .07327823    .031733766    .07550707    .031733766    .0754837    .015530783    .02824252
"51job Inc Sponsored ADR"       2016    .04755431    .01190903    .04755431   .012312967   .05298883  .006474514    .05298883    .00687845    .0479803    .011483036    .0479803    .011886973    .04755431    .01190903
"51job Inc Sponsored ADR"       2017   .036593165     .0425553   .036593165    .04254997   .07838735   .08434948    .07838735    .08434416    .07865115    .08461328    .07865115    .08460795    .036593165    .0425553
"51job Inc Sponsored ADR"       2018   .002892358 .00020230074   .002892358 .00020230074   .05686961   .05996427    .05686961    .05996427    .0634903    .06658496    .0634903    .06658496    .00289236    .00020229816
"8x8, Inc."                     2010   .004706667      .015818   .004706667   .004706667   .01256238 .0014510453    .01256238    .01256238    .011538368    .0226497    .011538368    .011538368    .07998595    .09109729
"8x8, Inc."                     2011     .1906471      .174274    .19297796     .1768446    .3657363    .3684912    .3678564    .3691403    .3684702    .3591835    .3704267    .3581331    .3582836    .346729
"8x8, Inc."                     2012  .0011356467   .002758044 .00050473184   .003659306  .018737625  .017115228    .01936854    .016213968    .009267982    .007645585    .009898897    .006744325    .07238847    .074010864
"8x8, Inc."                     2013   .021082655    .02054065    .02162466    .02026965   .08328375   .08274175    .08382576    .08247074    .08150784    .08096583    .08204985    .08069483    .01442558    .013883575
"8x8, Inc."                     2014    .01338719    .01550542   .013633498    .01560394   .10547615   .10759437    .10572246    .1076929    .10175686    .10387509    .10200316    .1039736    .0045912536    .0024730265
"8x8, Inc."                     2015    .02160153    .02419432    .02160153   .023784934   .02858303  .031175824    .02858303    .030766435    .021868344    .02446114    .021868344    .02405175    .0010313708    .0036241664
"8x8, Inc."                     2016    .02249694    .02477738    .02249694    .02468035   .02249694   .02477738    .02249694    .02468035    .02249694    .02477738    .02249694    .02468035    .008465279    .010745715
"8x8, Inc."                     2017    .08363133     .0822119     .0836105     .0822119    .0866249   .08520546    .08660406    .08520546    .064408265    .062988825    .064387426    .062988825    .065191776    .063772336
"8x8, Inc."                     2018    .05333638     .0508778        .0531    .05097234   .03116936  .028710777    .03093298    .028805315    .01252138    .010062797    .012284997    .010157336    .0097591    .007300517
"99 Cents Only Stores LLC"      2006  .0008692161 .00002581262  .0005038241 .00002581262  .014675104  .015570132    .016048145    .015570132    .01109101    .01198604    .01246405    .01198604    .06838533    .06749031
"99 Cents Only Stores LLC"      2007   .005973706 .00013968776   .004823336 .00010682005    .0395574   .04539142    .04070777    .04563793    .0435509    .04938492    .04470127    .04963142    .036372766    .04220679
"99 Cents Only Stores LLC"      2008   .015178392    .01901005   .013670854    .01932412  .004027253   .00785891    .0025197156    .008172981    .001565991    .0022656657    .0030735284    .0025797375    .022838546    .01900689
"99 Cents Only Stores LLC"      2009   .020643184   .000774108   .020643184  .0009725526   .09633993   .11775722    .09633993    .11601056    .09880747    .12022476    .09880747    .1184781    .029092923    .007675633
"99 Cents Only Stores LLC"      2010  .0003136955  .0010114766  .0001606733  .0009257842   .07991765   .07921986    .08007067    .07930555    .08273792    .08204013    .08289094    .08212582    .012712806    .01341059
"99 Cents Only Stores LLC"      2011    .07256336            0     .0727729            0    .3657363    .3684912    .3678564    .3691403    .3684702    .3758102    .3704267    .37686735    .50595725    .53290296
"A. M. Castle & Co."            2007  .0022954813    .00261611  .0022954813   .003205501   .05004604   .05495764    .05004604    .05554703    .04524966    .05016125    .04524966    .05075064    .04394333    .03903174
"A. M. Castle & Co."            2008     .0913299     .0957433     .0913299     .0957433   .14210442    .1465178    .14210442    .1465178    .1251683    .12958169    .1251683    .12958169    .02929031    .0337037
"A. M. Castle & Co."            2009    .04319113   .017429363    .04319113   .014474608   .07120092    .0969627    .07120092    .09991745    .11264203    .1384038    .11264203    .14135855    .0634171    .08917887
"A. M. Castle & Co."            2010   .009157779   .004994156   .009157779   .004994156   .11226244   .11642607    .11226244    .11642607    .13546339    .13962701    .13546339    .13962701    .04370815    .04787178
"A. M. Castle & Co."            2011    .03772841   .034577947   .036750678   .034577947    .3717508    .3686003    .37077305    .3686003    .356984    .3538335    .3560063    .3538335    .174707    .17785747
"A. M. Castle & Co."            2012     .0990796   .072723046    .09978436    .07230021    .2180187   .19166213    .21872343    .1912393    .1678234    .14146683    .16852814    .141044    .24592987    .27228642
"A. M. Castle & Co."            2013     .0543656    .03608531     .0543656   .036423832   .19709557   .21537587    .19709557    .21503735    .24010104    .25838134    .24010104    .2580428    .021030463    .002750166
"A. M. Castle & Co."            2014    .17762762    .10856872    .17627352    .10856872    .6831738    .6143943    .6763842    .6143943    .5966482    .5275893    .5952941    .5275893    .25206226    .3211212
"A. O. Smith Corporation"       2006   .005301367  .0010280343   .005301367  .0010282052  .005866192  .010139525    .005866192    .010139354    .0009403452    .005213678    .0009403452    .005213507    .03901444    .034741104
"A. O. Smith Corporation"       2007   .005001438        .0058   .004735304   .007130991  .032263838  .031465277    .032529972    .030134283    .04065246    .0398539    .0409186    .03852291    .008792259    .00959082
"A. O. Smith Corporation"       2008    .04446613    .04557883    .04517945    .04574984    .1710858    .1721985    .17179912    .1723695    .1774951    .1786078    .17820844    .17877883    .01363136    .012518667
"A. O. Smith Corporation"       2009   .015428863   .022937804    .01458191    .02169573   .08539367   .07788473    .08624062    .0791268    .09121913    .08371019    .09206608    .08495226    .14876318    .15627213
"A. O. Smith Corporation"       2010    .05127329   .036748406    .05094681    .04766264   .10471006   .09018518    .10438358    .10109942    .1002719    .085747    .0999454    .09666125    .030802824    .01627794
"A. O. Smith Corporation"       2011  .0032867645    .00437542   .008171218   .007908613  .011902422  .012991074    .016786873    .01652427    .013516717    .01460537    .018401168    .018138565    .06654631    .06763497
"A. O. Smith Corporation"       2012   .014697907   .012114756   .014947158   .012205384  .036519736   .03910289    .036270484    .03901226    .03697255    .0395557    .036723297    .03946507    .04051258    .03792942
"A. O. Smith Corporation"       2013    .00643095   .006938322    .00643095   .006906612   .03886429   .03835692    .03886429    .03838863    .03821892    .03771155    .03821892    .03774326    .033338398    .033845775
"A. O. Smith Corporation"       2014  .0017912495  .0023225804  .0018283278   .002384501   .03116286  .031694196    .03119994    .03175611    .032190673    .032722004    .032227755    .032783926    .01116112    .011692453
"A. O. Smith Corporation"       2015  .0012660875  .0004506293  .0011597235  .0004506293 .0006649531 .0014804117    .0007713176    .0014804117    .003146861    .0039623193    .003253225    .0039623193    .02236493    .02318039
"A. O. Smith Corporation"       2016  .0007080015 .00049027544   .000751338 .00049027544 .0011721104  .001389835    .0011287741    .001389835    .003645189    .003862914    .003601853    .003862914    .029173976    .0293917
"A. O. Smith Corporation"       2017  .0011812038  .0012057022  .0011812038  .0004420274   .01487348   .01484898    .01487348    .015612656    .017123219    .017098717    .017123219    .017862394    .005184133    .005159631
"A. O. Smith Corporation"       2018 .00049902085 .00011406658  .0005533616  .0000993799  .006449405  .005836319    .006503746    .005851004    .0040893666    .003476281    .0041437075    .003490966    .013753258    .014366344
"A.C. Moore Arts & Crafts Inc." 2006   .036451545   .018925773   .035764262   .018238489   .08194973    .0994755    .08263701    .1001628    .0876755    .10520127    .08836278    .10588856    .006163504    .01136227
"A.C. Moore Arts & Crafts Inc." 2007    .01998846   .001622058    .01998846 .00014536225   .05620247   .03783607    .05620247    .03635937    .05513395    .036767542    .05513395    .035290845    .03702586    .05539227
"A.C. Moore Arts & Crafts Inc." 2008    .05464363    .05737091    .05482545    .05737091  .020912945  .018185671    .020731125    .018185671    .032008216    .02928094    .031826396    .02928094    .005490936    .0027636625
"A.C. Moore Arts & Crafts Inc." 2009    .17124286  .0019714285     .1623143  .0019714285    .3867867   .56000096    .3957153    .56000096    .3137952    .4870095    .3227238    .4870095    .50595725    .53290296
"A.C. Moore Arts & Crafts Inc." 2010    .06962925   .001602041    .06962925   .001602041   .12150179     .189529    .12150179    .189529    .16627245    .23429967    .16627245    .23429967    .26878652    .33681375
"AAON, Inc."                    2015   .001612327 .00027244305   .001612327 .00027244305   .00467164  .006011527    .00467164    .006011527    .008669252    .010009138    .008669252    .010009138    .028037423    .02937731
"AAON, Inc."                    2016   .000798019   .001228682   .000798019   .001228682 .0043858737   .00481654    .0043858737    .00481654    .0004182495    .0008489154    .0004182495    .0008489154    .03378661    .033355944
"AAON, Inc."                    2017  .0002139183  .0016257185  .0002139183  .0023319214 .0017332844 .0003214851    .0017332844    .0003847182    .0009333566    .002345156    .0009333566    .003051359    .019920645    .021332445
"AAON, Inc."                    2018  .0020643051 .00015694823  .0020643051 .00011553134   .00259787 .0006905142    .00259787    .0004180353    .0044903774    .002583021    .0044903774    .0023105424    .016668528    .01476117
"AAR CORP."                     2006  .0082943635   .008225052  .0082943635   .009338205   .04046746   .04053678    .04046746    .03942362    .03831016    .03837947    .03831016    .03726632    .1783592    .1782899
"AAR CORP."                     2007   .003636862  .0026947584    .00286605  .0026947584   .05068785   .05162995    .05145866    .05162995    .0410632    .0420053    .04183401    .0420053    .14101297    .14007086
"AAR CORP."                     2008   .009105706   .006269787   .009030765   .006401262   .05749735   .05466143    .05742241    .0547929    .06026013    .05742421    .06018519    .05755569    .04801719    .05085311
"AAR CORP."                     2009   .013209126  .0004790875    .00984139  .0004790875  .024330314    .0106421    .02096258    .0106421    .02627539    .012587175    .02290765    .012587175    .023599077    .009910863
"AAR CORP."                     2010   .006699739    .00102698   .006140122  .0013533507   .03872751  .033054754    .03816789    .03338112    .06101678    .05534403    .06045717    .0556704    .1517052    .14603247
"AAR CORP."                     2011   .007712414   .001479432   .007712414  .0013884237   .06646837   .05727653    .06646837    .05736754    .05592322    .04673138    .05592322    .04682239    .12315482    .13234666
"AAR CORP."                     2012    .02956286   .008245696    .03015493   .008245696   .08219576    .0608786    .08278784    .0608786    .0916058    .07028863    .09219787    .07028863    .013701297    .03501846
"AAR CORP."                     2013   .014343148    .00706424   .014075482   .006848501   .07274885   .06546994    .072481185    .065254204    .07527548    .06799658    .07500782    .06778084    .08090564    .08818454
"AAR CORP."                     2014    .12776116    .07647776    .12808639    .07647776   .00966556   .06094896    .00934032    .06094896    .04312363    .09440703    .04279839    .09440703    .13066672    .1819501
"AAR CORP."                     2016    .00358197  .0021240015    .00358197  .0022506656  .022760343  .024218313    .022760343    .024091646    .01924402    .020701993    .01924402    .020575326    .17214277    .1706848
"AAR CORP."                     2017   .000751891   .005411498  .0007609682  .0019621786   .01958217   .02424177    .018069308    .020792454    .009424418    .014084022    .007911559    .010634705    .11471897    .11005937
"AAR CORP."                     2018   .007679816  .0041674725   .008188852   .002589463  .010508485   .01402083    .009999454    .01559884    .017906226    .02141857    .017397195    .02299658    .11140133    .11491367
end