19.08.2015 Views

How to Get Data into Shazam

How to Get Data into Shazam - Athene

How to Get Data into Shazam - Athene

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ECN201Econometrics<strong>How</strong> <strong>to</strong> read Excel files in<strong>to</strong> <strong>Shazam</strong><strong>How</strong> <strong>to</strong> <strong>Get</strong> <strong>Data</strong> in<strong>to</strong> <strong>Shazam</strong>Step by stepStep 1 <strong>Get</strong> data from ECN201 homepages.You will find all the dataset used in the exercises by clicking on Exercises. Save theappropriate dataset on your computer. This can either be done by opening the link andsaving the file or by clicking on the right hand mouse but<strong>to</strong>n and choosing save targetas. As an example you can save the data for Problem set #6 in a file called data2.xlson a diskette. The address of the file is then: a:\data2.xlsNote: It is important that EXCEL data is on a sheet named Sheet1 and that thevariable names are in the first row.Step 2 Read an Excel dataset in <strong>Shazam</strong> Professional EditionWrite the following program in the Command Edi<strong>to</strong>r.sample 1 55read(a:\data2.xls) obs y xThe first line lets <strong>Shazam</strong> know how many observations <strong>to</strong> read. The second line tellsit where it can find the file <strong>to</strong> read (address in parenthesis) and what variables <strong>to</strong> read.Step 3 Create a <strong>Shazam</strong> dataset from the data.Write the following line in the Command Edi<strong>to</strong>r.write(a:\data2.dat) obs y xThis command is just like read but this time a new file is created. Notice the extensionof the file is .dat which is the extension for <strong>Shazam</strong> dataset files. The write commandis only necessary when you want <strong>to</strong> access the data in other Command Edi<strong>to</strong>rs. If thatis not your intention you may omit this step.Step 4 Check if the file was read correctly.Add the lines:print obss<strong>to</strong>p<strong>to</strong> your Command Edi<strong>to</strong>r. The line you have added prints the variable obs. You dothis <strong>to</strong> check if it was read correctly. When you run the Command Edi<strong>to</strong>r the outputshould show the observation numbers correctly from 1 <strong>to</strong> 55.


ECN201Econometrics<strong>How</strong> <strong>to</strong> read text files from the Internet in<strong>to</strong> ExcelMany of you will need <strong>to</strong> import data in<strong>to</strong> <strong>Shazam</strong> from a source on the Internet when you doyour term paper. We recommend that you import the data trough Excel. Here is an example ofhow you can do this. Those of you familiar with Excel will know that many other methodsexist. This is just an example.Step 1 As an example you can import data from the Internet on the interest rate ofNorwegian government bonds (Norske obligasjonsrenter). The data is availableon the home page of the Norwegian central bank:http://www.norges-bank.no/stat/renter/pmarked/a_obl_n.htmlCopy only the data lines. They should read:2003 4.24 4.58 5.042002 6.39 6.36 6.382001 6.44 6.31 6.242000 6.61 6.38 6.221999 5.39 5.39 5.521998 5.32 5.34 5.401997 4.62 5.12 5.891996 5.46 5.98 6.78Step 2 Open Word and paste the observations in the document. Save the data as a Text Onlyfile ( .txt) on your diskette. Call it bonds.txt. Close the file.Step 3 Open bonds.txt with Excel. When you try <strong>to</strong> open a .txt file in Excel the Text ImportWizard (TIW) will appear.Step 1 mark for Fixed With and click Next.Step 2 Excel will now suggest column separation.Step 3 if the separation is OK then click Finish.Step 4 Notice that the workbook only includes one worksheet called bonds. Rename the sheet<strong>to</strong> Sheet1 by double clicking on the sheet name and write Sheet1.Step 5 The Norwegian government bonds data has no variable names. Add a row at the <strong>to</strong>pand write the variable names year y3 y5 and y10 in the first row of the four datacolumns.Step 6 Save the workbook by using Save As and define it as a Microsoft Excel Workbook.Call the workbook bonds.xls and save it on your diskette.Step 7 Follow the steps 2 <strong>to</strong> 4 on the previous page <strong>to</strong> get your Excel dataset in<strong>to</strong> <strong>Shazam</strong>The following program in the Command Edi<strong>to</strong>r works as long as you have followedthe instructions.sample 1 8read(a:\bonds.xls) year y3 y5 y10print year y3 y5 y10s<strong>to</strong>p


ECN201EconometricsThe problem with decimal point, “.”, versus decimal comma “,”.There are two ways of decimal separa<strong>to</strong>rs. Europeans use commas, e.g. 1/10=0,1. Americanson the other hand use a decimal point, i.e., 1/10=0.1. This causes problems for example whenyou get data from the Internet. While the Norwegian Central Bank reports data with decimalcomma the American Federal Reserve uses decimal points. We assume that most studentshave their computers configured according <strong>to</strong> European standards. If you want <strong>to</strong> get decimalpoint numbers in<strong>to</strong> <strong>Shazam</strong> you can follow the following instructions. Note: if yourcomputer uses the American configuration you can use these instructions <strong>to</strong> get decimalcomma data in<strong>to</strong> <strong>Shazam</strong> by replacing “comma” with “point” in the following steps.Step 1 Assume that you want <strong>to</strong> get the following data in<strong>to</strong> <strong>Shazam</strong>:obs x y1 0.36 8.12 0.89 0.93 0.57 1.44 0.16 7.15 0.58 3.06 0.83 6.27 0.41 6.38 0.69 0.6Step 2 Open Word and paste the observations and variable names in the document. ChooseReplace from the Edit menu and put “.” where it says Find what and “,” where it saysReplace with. Then choose Replace all.Step 3 Save the data as a Text Only file ( .txt) on your diskette. Call it test.txt. Close the file.Step 4 Open test.txt with Excel. When you try <strong>to</strong> open a .txt file in Excel the Text ImportWizard (TIW) will appear.Step 1 mark for Fixed With and click Next.Step 2 Excel will now suggest column separation.Step 3 if the separation is OK then click Finish.Step 5 Notice that the workbook only includes one worksheet called test. Rename the sheet <strong>to</strong>Sheet1 by double clicking on the sheet name and write Sheet1.Step 6 Save the workbook by using Save As and define it as a Microsoft Excel Workbook.Call the workbook test.xls and save it on your diskette.Step 7 Follow the steps 2 <strong>to</strong> 4 on the previous page <strong>to</strong> get your Excel dataset in<strong>to</strong> <strong>Shazam</strong>The following program in the Command Edi<strong>to</strong>r works as long as you have followedthe instructions.sample 1 8read(a:\test.xls) obs x yprint obs x ys<strong>to</strong>p

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!