Hi, I am currently having daily data and I would like to convert it to yearly data. Ultimately, I would need to reshape the currency exchange rates from a wide to long, and regress stock returns(ret) and index(sprtrn) against each currency exchange rates for each company.

I initially collapsed all variables (ret, sprtrn, exchange rates) by company (hcomnam) and year, and from there reshaped the exchange rates from wide to long. However, after reshaping it, I was unable to do a regression because sprtrn and ret gave a constant value for per company per year. I am not sure how I should go around this. I was thinking maybe I did something wrong while converting daily to yearly data? Or maybe the sequence between collapsing, reshaping, and regressing is wrong?

This was my initial code:
Code:
gen yr=year(date)
rename yr year
collapse ret sprtrn exalus exauus exbeus exbzus excaus exchus exdnus execus exeuus exfnus exfrus exgeus exgrus exhkus exinus exirus exitus exjpus exkous exmaus exmxus exneus exnous exnzus expous exsdus exsfus exsius exslus exspus exszus extaus exthus exukus exusal exusec exuseu exusir exusnz exusuk exvzus, by(hcomnam year)
foreach v of varlist exalus-exvzus{
rename `v' u_`v'
 }
gen long seq =_n
reshape long u_, i(seq) j(exc) string
rename exc country_pairs_exchange
rename u_ exchange_rates
rangestat (reg) ret sprtrn exchange_rates, by(hcomnam year) interval(year . .)
This is the daily sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float year double date str32 hcomnam double(ret sprtrn exalus exauus exbeus exbzus excaus exchus exjpus exkous exfnus)
2000 14612 "SELECT SECTOR SPDR TRUST"          -.019221041351556778 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CBIZ INC"                          -.014814814552664757 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "P G & E CORP"                       -.03658536449074745 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "E C I TELECOM LTD"                 -.003952569328248501 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ISHARES INC"                         .01937984488904476 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "P P L CORP"                        -.030054645612835884 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "TARRAGON CORP NEV"                 -.012195121496915817 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "VICOR CORPORATION"                 -.027006173506379128 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "D R S TECHNOLOGIES INC"             -.03896103799343109 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "PLAINS RESOURCES INC"               -.05999999865889549 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "WEST COAST BANCORP ORE NEW"         .004629629664123058 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "NATIONAL BANKSHARES INC"            .012658228166401386 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "AMERICAN WATER WORKS INC"            -.0117647061124444 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CALIFORNIA WATER SERVICE GROUP"     -.07422680407762527 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "BANK ONE CORP"                               -.02734375 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "AMWEST INSURANCE GROUP INC"                           0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "IVOW INC"                            .17499999701976776 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MODTECH HOLDINGS INC"                .02083333395421505 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "IMPATH INC"                         .007371007464826107 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MOORE WALLACE INC"                                    0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "PRIVATE MEDIA GROUP INC"              .0347222238779068 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "HEARTPORT INC"                       .07894736528396606 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "STRATEGIC GLOBAL INCOME FUND INC"                .03125 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CENTER TRUST INC"                   -.05806451663374901 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "AVIGEN INC"                       -.0030241934582591057 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "JO ANN STORES INC"                                    0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "STONEX GROUP INC"                  -.024390242993831635 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "TECH DATA CORP"                      -.0276497695595026 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "P C C GROUP INC"                     .23076923191547394 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "PLEXUS CORP"                       -.017045455053448677 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "STATEWIDE FINANCIAL CORP"          -.024752475321292877 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MORGAN STANLEY TRUSTS"                                0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "SOUTHDOWN INC"                      -.04116222634911537 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "R P M INTERNATIONAL INC"           -.030674846842885017 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MCRAE INDUSTRIES INC"                                 0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "RENAISSANCE LEARNING INC"           .044692736119031906 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "POTTERS FINANCIAL CORP"              .05263157933950424 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "KRATOS DEFENSE & SECUR SOLS INC"     .03295128792524338 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "PACIFIC GATEWAY PPTYS INC MD"                         0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "INTEGRITY MEDIA INC"                 .03999999910593033 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "SELECT SECTOR SPDR TRUST"          -.012211669236421585 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ABERDEEN ASIA PACIFIC INCOME FD"     .02469135820865631 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "THERMO INSTRUMENT SYSTEMS INC"                        0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "FIRST REGIONAL BANCORP"                               0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MORTON INDUSTRIAL GROUP INC"                          0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "USURF AMERICA INC"                   .10294117778539658 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ARCH CAPITAL GROUP LTD NEW"          -.0891089141368866 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CAPSULE COMMUNICATIONS INC"          .02500000037252903 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "FEDDERS CORP"                       .022727273404598236 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "M C N ENERGY GROUP INC"            -.021052632480859756 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "FIELDWORKS INCORPORATED"                              0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "C T O REALTY GROWTH INC"           -.019607843831181526 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "EMVELCO CORP"                         .0810810774564743 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "L V M H MOET HENNESSY VUITTON"     -.012362637557089329 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "C B L & ASSOCIATES PPTYS INC"     -.0060606058686971664 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "BANKUNITED FINANCIAL CORP"          -.10236220806837082 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "NASHUA CORP"                         .01666666753590107 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "AMERITRANS CAPITAL CORP"            -.05511811003088951 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "THORATEC CORP"                      -.06410256773233414 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "JOURNAL REGISTER CO"                -.04048582911491394 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "NORTHERN TRUST CORP"                -.04775943234562874 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "STOLT NIELSEN S A"                  .035087719559669495 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CAROLINA SOUTHERN BK SPARTANBURG"    .03365384787321091 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "WORLD FUEL SERVICES CORP"                             0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "HOME STAKE OIL & GAS CO"                              0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CAPTEC NET LEASE REALTY INC"         .03333333507180214 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ACMAT CORP"                                           0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "BLACKROCK MUNIHLDGS NJ QLTY FD"     .005434782709926367 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CADILLAC FAIRVIEW CORP"             .010869565419852734 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ATRION CORP"                                          0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "T J INTERNATIONAL INC"            -.0007440476329065859 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "SYNTHETECH INC"                      .05000000074505806 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "D I S C INC"                        -.03030303120613098 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CONCERO INC"                       .0031347961630672216 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "TRIPOS INC"                         -.03804347664117813 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MARKETING SPECIALISTS CORP"                           0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "KOLLMORGEN CORP"                   -.025380710139870644 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "A D C TELECOMMUNICATIONS INC"      -.000861326465383172 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "INTERLEAF INC"                      -.00929368007928133 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "EVANS & SUTHERLAND COMPUTER CORP"    .08743169158697128 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "CINTAS CORP"                       -.016470588743686676 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "AZUREL LTD"                          .06060606241226196 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "COHERENT INC"                       -.02570093423128128 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "T ROWE PRICE GROUP INC"            -.049069374799728394 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "E D P ENERGIAS DE PORTUGAL S A"     -.00358422938734293 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "INSIGHT HEALTH SERVICES CORP"         .1428571492433548 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "RELIANCE GROUP HOLDINGS INC"         .06603773683309555 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "RICHARDSON ELECTRONICS LTD"         -.03333333507180214 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ENGLOBAL CORP"                        .0714285746216774 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "BANK GRANITE CORP"                  -.06104651093482971 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "EASTERN ENTERPRISES"               -.007616974879056215 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ZIEGLER COMPANY INC"               -.012552301399409771 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "MERCHANTS NEW YORK BANCORP INC"    -.007299270015209913 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "PENN AMERICA GROUP INC"                               0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "PAIRGAIN TECHNOLOGIES INC"          -.04845815151929855 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "BROOKDALE LIVING COMM INC"          -.04040404036641121 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "D V I INC"                          -.02469135820865631 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "LIBERTY BANCORP INC NJ"                               0 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "ERICSSON"                            .03615604341030121 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
2000 14612 "COMVERSE TECHNOLOGY INC"             .06347150355577469 -.009549090000000001 1.5172204521316948 . . 1.805 1.4465 8.2798 101.7 1128 .
end
format %td date
Any help would be appreciated. Thank you!