Stata - Reading and Converting Data
Open your spreadsheet in Excel. Use your mouse to highlight the columns in your spreadsheet you want to copy to Stata. Make sure you highlight complete columns, i.e., do not ignore a header line if one exists (a header line contains variable names). Next, select Copy from the Edit menu in Excel. At this point you can quit Excel but doing so is not required. Start Stata as you normally would. From the command line type edit
and you should now see a blank spreadsheet. Select Paste from the Edit menu in Stata, and you should see your data. Close the edit window, and you are done.
Select Save or Save As from the Stata File menu. You will be prompted for a directory to save your dataset. Choose the appropriate directory, type a name for the file, and then save the file. To load your dataset, just double-click it. This will start Stata and automatically load your data.
The problem is that your browser thinks the .dta file is a text file. Right click the file (or Control-Click if using a one-button mouse on a Mac) and save the file to your computer. Ensure the file has the correct .dta suffix; sometimes browsers will add a .txt suffix after a .dta suffix. If the file’s suffix is not .dta, rename the file with a .dta suffix.
Use the insheet command. Let’s suppose that the file you want to read is called newdata.txt and is on your Desktop. Click the File menu and choose Select Working Folder. Choose your Desktop as the folder. To see if your ascii file called newdata.txt is indeed in the folder, type ls to list the files in your working directory (which you set to the Desktop). If you do not see the file, then stop and either move the file to your Desktop or select a working folder that contains the file. Now, type insheet using newdata.txt
to read the file into Stata. This assumes that the file has a header line.
Steps for converting Excel to XML and then reading XML into Stata:
In Excel:
In Stata: