This essay has been submitted by a student. This is not an example of the work written by professional essay writers.
Bank

How to download data and set up a new data set in Stata

Pssst… we can write an original essay just for you.

Any subject. Any type of essay. We’ll even meet a 3-hour deadline.

GET YOUR PRICE

writers online

Part B: How to download data and set up a new data set in Stata

ADD NEW VARIABLE

  1. Go at: http://data.worldbank.org/
  2. Have a look at the window and choose: Indicators
  3. Go to the set of indicators with title: Economy & growth and choose:GDP (current US$)
  4. Choose: download data\EXCEL
  5. Save the new file at your desktop as gdp_original
  6. Mark and delete the rows 1-3 and do the same for the columns B up to AR. So, you have to remain with the years 2000-2017 (i.e. 18 years)
  7. Save the file as: gdp
  8. Mark the cells from B1-P1 with the years
  9. Ctrl+f to open the find and replace window
  10. Find: 20; Replace with: newvarname20 let say: gdp20 and choose: replace all
  11. Save the file as: gdp
  12. Open a stata file and open the menu: FileàimportàExcel spreadsheet: import first row as variable names-browse-ok (or select all the table copy and paste it into the data editor of a new stata file).
  13. Choose that the first line contains variables names.
  14. Open the data editor in stata. Open the menu: DataàVariables manager.
  15. Choose all the variables of this list on your left except the first.Choose on your right (format) createàtotal digits: 15, to increase the numbers that STATA shows to you. Alternatively you can type the command: format %15.0g gdp2000-gdp2017 at the command line.
  16. Create an index variable: generate cnameid=_n
  17. Rename the variable CountryName typing the command: rename CountryNamecname
  18. Place the variable cnameid before the variable cname: order cnameid, before(cname)
  19. Add label for the variable cnameid: label variable cnameid “Country id”
  20. Save the stata file as gdp
  21. Open the data editor and have look of your dataset.
  22. Reshape your data from wide to long giving the order: reshape long  gdp, i( cnamecnameid) j(year)
  23. Open the data editor and have a look again.
  24. Sort your data set by cnameid: sort cnameid year
  25. Save the stata file as gdp_final
  26. Open the data editor and have a look again.

ADD NEW VARIABLE

  1. Go at: http://data.worldbank.org/
  2. Go to the set of indicators with title: Economy & growth and choose: Foreign direct investment, net inflows (BoP, current US$)
  3. Choose: download data\EXCEL
  4. Save the new file at your desktop as fdi_original
  5. Mark and delete the rows 1-3 and do the same for the columns B up to AR. So, you have to remain with the years 2000-2017 (i.e. 18 years)
  6. Save the file as: fdi
  7. Mark the cells from B1-P1 with the years
  8. Ctrl+f to open the find and replace window
  9. Find: 20; Replace with: newvarname20 let say: fdi20 and choose: replace all
  10. Save the file as: fdi
  11. Open a stata file and open the menu: FileàimportàExcel spreadsheet: import first row as variable names-browse-ok (or select all the table copy and paste it into the data editor of a new stata file).
  12. Choose that the first line contains variables names
  13. Open the data editor in stata. Open the menu: DataàVariables manager.
  14. Choose all the variables of this list on your left except the first.Choose on your right (format) createàtotal digits: 15, to increase the numbers that STATA shows to you. Alternatively, you can type the command: format %15.0g fdi2000-fdi2017 at the command line.
  15. Create an index variable: generate cnameid=_n
  16. Rename the variables CountryNamewith:rename CountryNamecname
  17. Place the variable cnameid before the variable cname: order cnameid, before(cname)
  18. Add label for the variable cnameid: label variable cnameid “Country id”
  19. Save the stata file as fdi
  20. Open the data editor and have look of your dataset.
  21. Reshape your data from wide to long giving the order: reshape long  fdi, i(cnamecnameid) j(year)
  22. Open the data editor and have a look again.
  23. Sort your data set by cnameid: sort cnameid year
  24. Save the stata file as fdi_final(pay attention: you must save the file in the same folder you saved the gdp_final.dta).
  25. Open the data editor and have a look again.
  26. Close the fdi_final.dta
  27. Open the stata file gdp_final
  28. To merge data from the fdi.dta into the dataset of gdp.dta give the order: merge 1:1 cname year using fdi_final
  29. Put the year variable at the beginning: order year cnameid, before(cname)
  30. Sort your dataset by cnameid year: sort cnameid year
  31. Delete an unnecessary variable: drop _merge
  32. label variable gdp “Gross domestic product”
  33. label variable fdi “Foreign direct investment”
  34. Save the new file as:merged_data

Before running panel data analysis (please leave these steps for the end of the semester and after the completion of our lecture about panel data analysis)

  1. Denote to the program that you use panel data by giving the order: xtsetcnameid year
  2. Run: xtreggdpfdi,fe r

Find out more useful information at:http://dss.princeton.edu/training/

 

 

  Remember! This is just a sample.

Save time and get your custom paper from our expert writers

 Get started in just 3 minutes
 Sit back relax and leave the writing to us
 Sources and citations are provided
 100% Plagiarism free
error: Content is protected !!
×
Hi, my name is Jenn 👋

In case you can’t find a sample example, our professional writers are ready to help you with writing your own paper. All you need to do is fill out a short form and submit an order

Check Out the Form
Need Help?
Dont be shy to ask