Here's an example do file:. When you give the filename of the spreadsheet you do not need to include. The firstrow option tells Stata that the first row of the spreadsheet contains the names of the variables. Otherwise it will name the variables A, B, C, etc. There are other options that let you specify which which worksheet to read, or to only read in part of a spreadsheet so you can skip titles or notes that aren't really data.
If you have a complicated spreadsheet you might click File , Import Excel , tweak the options in the dialog box you get until it can read the spreadsheet successfully, then copy the resulting command into your do file.
A CSV file is really just a text file, but structured so that each line of text represents one observation and each variable is separated by a comma. Hence the name, comma-separated variable file. Stata: Data Analysis and Statistical Software. Go Stata. Purchase Products Training Support Company. Preview lets you see how the data will look in Stata even before you import them, even from data on the Internet Automatic delimiter detection for commas, tabs, semicolons, colons, and pipes May specify delimiter, including multiple-character delimiters May specify multiple delimiters Variable names may be on any row in the file Import selected row ranges Import selected column ranges Automatic storage types Inspect and manually control data types for each column if desired Support for long strings Double quotes to delimit strings Allows "" to mean real double quotes in data as used by Excel Numeric parsing for different numeric formats is supported based on locale Automatic encoding detection Exporting May specify delimiter Optionally save variable names in first row of data Support for long strings.
Stata New in Stata Why Stata? Order Stata. Company Contact us Customer service Announcements Search. Use split inside Stata parsing on commas. Anders Alexandersson. Since the file name ends with "excel file", perhaps the file format is Excel rather than plain text? You could make a backup copy, change the file name extension to ".
Does the first line in the file contain the listed data or something else such as variable names? Edit: Missed Nick's Stata solution which looks good to me as usual. Last edited by Anders Alexandersson ; 22 Mar , Reason: Edit: Missed Nick's Stata solution which looks good to me as usual. Dear Nick and Anders, thanks a lot! I have indeed used split command with parse , , and it worked marvelously. Anders, the file was named an excel, but it was in csv format.
Thanks again!
0コメント