Hi all experts,
I have data on exchange rates (local currency per USD) for 26 countries (reporters) from 1990 till 2018. I want to generate country pairs. I used a command:
I wanted to build country-pairs. I used a command:
As a result I have in column partner USA, which is the last country. After analyzing my loop I know it is incorrect. However, I have no idea what to do. My goal is to calculate exchange rate between country pairs. I calculated it in Excel before. I wanted to do it in Stata to double check.
Here is sample of my data
I have data on exchange rates (local currency per USD) for 26 countries (reporters) from 1990 till 2018. I want to generate country pairs. I used a command:
Code:
expand 26
Code:
gen partner="" levelsof reporter,local(partners) foreach partner of local partners{ forvalues i=1/26{ replace partner="`partner'" } }
Here is sample of my data
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year str17 reporter double EXCH_USD_rep 1990 "AUS" 1.28105666666667 1991 "AUS" 1.28375583333333 1992 "AUS" 1.36164833333333 1993 "AUS" 1.47056 1994 "AUS" 1.36775083333333 1995 "AUS" 1.3490325 1996 "AUS" 1.27786333333333 1997 "AUS" 1.34738 1998 "AUS" 1.59182833333333 1999 "AUS" 1.54995 2000 "AUS" 1.72482666666667 2001 "AUS" 1.9334425 2002 "AUS" 1.8405625 2003 "AUS" 1.54191416666667 2004 "AUS" 1.3597525 2005 "AUS" 1.30947333333333 2006 "AUS" 1.3279734405 2007 "AUS" 1.1950725 2008 "AUS" 1.19217833333333 2009 "AUS" 1.28218881008452 2010 "AUS" 1.09015948638677 2011 "AUS" .969463201496735 2012 "AUS" .965801030658708 2013 "AUS" 1.03584309652054 2014 "AUS" 1.10936329281692 2015 "AUS" 1.33109026245502 2016 "AUS" 1.34521397601947 2017 "AUS" 1.30475807671592 2018 "AUS" 1.33841214646451 1990 "AUT" .826275589921731 1991 "AUT" .848520744460513 1992 "AUT" .798623576520861 1993 "AUT" .845344941607378 1994 "AUT" .83005457729846 1995 "AUT" .732651177663278 1996 "AUT" .769358226201464 1997 "AUT" .886913802751393 1998 "AUT" .899624281447352 1999 "AUT" .938283072395283 2000 "AUT" 1.08270508132602 2001 "AUT" 1.11653308564463 2002 "AUT" 1.05755899623965 2003 "AUT" .88404792718493 2004 "AUT" .803921647747618 2005 "AUT" .803800192161442 2006 "AUT" .796432730949102 2007 "AUT" .729672399984083 2008 "AUT" .679922680042729 2009 "AUT" .716957702016136 2010 "AUT" .754308990105961 2011 "AUT" .718413898653317 2012 "AUT" .778338120416812 2013 "AUT" .752945122701996 2014 "AUT" .752728196932603 2015 "AUT" .901296423367096 2016 "AUT" .903421436257263 2017 "AUT" .885205508269372 2018 "AUT" .846772667108111 1990 "BEL" .828408102151964 1991 "BEL" .846514245201401 1992 "BEL" .796965287469726 1993 "BEL" .857624832981738 1994 "BEL" .829364971157588 1995 "BEL" .73079011103151 1996 "BEL" .767515536726665 1997 "BEL" .886811816588539 1998 "BEL" .899818789833391 1999 "BEL" .938283072395283 2000 "BEL" 1.08270508132602 2001 "BEL" 1.11653308564463 2002 "BEL" 1.05755899623965 2003 "BEL" .88404792718493 2004 "BEL" .803921647747618 2005 "BEL" .803800192161442 2006 "BEL" .796432730949102 2007 "BEL" .729672399984083 2008 "BEL" .679922680042729 2009 "BEL" .716957702016136 2010 "BEL" .754308990105961 2011 "BEL" .718413898653317 2012 "BEL" .778338120416812 2013 "BEL" .752945122701996 2014 "BEL" .752728196932603 2015 "BEL" .901296423367096 2016 "BEL" .903421436257263 2017 "BEL" .885205508269372 2018 "BEL" .846772667108111 1990 "CAN" 1.16677362666667 1991 "CAN" 1.14572584416667 1992 "CAN" 1.20872292 1993 "CAN" 1.29008788166667 1994 "CAN" 1.3656734475 1995 "CAN" 1.37244541833333 1996 "CAN" 1.36352163583333 1997 "CAN" 1.38459802833333 1998 "CAN" 1.48350530166667 1999 "CAN" 1.48570481916667 2000 "CAN" 1.485394095 2001 "CAN" 1.548839955 2002 "CAN" 1.57034283416667 end
Comment