正在加载图片...
Reading Data from Text Files (ASCII fixed format) Finally,let's practice reading the data "fix gss93subset.dat,"which is an ASCII fixed format file. This type of data always comes with a codebook that specifies which column corresponds to which variable.Take a look at this text file (left below;notice there is no variable name header) and its codebook(right below) 113203143 Variable Name Column Number 21502044 313252043 id 1-4 42504045 wrkstat 5 55501078 marital 6 651252283 711222255 agewed 7-8 851243275 sibs 9-10 913221231 childs 11 102501054 age 12-13 Now,unlike the previous examples,there is no easy point-and-click method to read this type of data.What do we do then?The best way is to write syntax commands ourselves to bring in this data.Let's open a new syntax file for this work.From the menu bar at the top,go: File New Stntax You now should be seeing the SPSS Syntax Editor,which is another important window in the SPSS environment (as I emphasized in the introduction,you should eventually learn to use and write the Syntax file for your work.You are now getting a little glimpse of it...).Let's save it as "verybasicspss"in your working directory.Now,let's type the following commands(be sure to specify the file location where you saved the file "fix gss93subset.dat"). data list fixed file='[specify your working directory]lfix_gss93subset.dat' Always end your comment with a period. id 1-4 wrkstat 5 marital 6 agewed 7-8 sibs 9-10 childs 11 age 12-13.- The command DATA LIST is to read a text format data file by assigning names and formats to each variable in the file.The keyword FIXED follows to tell SPSS that our data is a fixed format (actually,this is the SPSS default so you can skip it).The command FILE ="file location/name here"specifies your fixed format file and its location.After the slash(/)we provide SPSS with variable definitions(the variable names and column numbers)from the codebook. Two syntax rules you must remember here: 1.Notice that the whole command ended with a period (".")In SPSS,each command in SPSS must be completed with a period“.”. 2.SPSS Syntax is NOT case-sensitive.Reading Data from Text Files (ASCII fixed format) Finally, let’s practice reading the data “fix_gss93subset.dat,” which is an ASCII fixed format file. This type of data always comes with a codebook that specifies which column corresponds to which variable. Take a look at this text file (left below; notice there is no variable name header) and its codebook (right below). 11320 3143 215 0 2044 31325 2043 425 0 4045 555 0 1078 65125 2283 71122 2255 85124 3275 91322 1231 1025 0 1054 Variable Name Column Number id 1-4 wrkstat 5 marital 6 agewed 7-8 sibs 9-10 childs 11 age 12-13 Now, unlike the previous examples, there is no easy point-and-click method to read this type of data. What do we do then? The best way is to write syntax commands ourselves to bring in this data. Let’s open a new syntax file for this work. From the menu bar at the top, go: File New Stntax You now should be seeing the SPSS Syntax Editor, which is another important window in the SPSS environment (as I emphasized in the introduction, you should eventually learn to use and write the Syntax file for your work. You are now getting a little glimpse of it…). Let’s save it as “verybasicspss” in your working directory. Now, let’s type the following commands (be sure to specify the file location where you saved the file “fix_gss93subset.dat”). data list fixed file='[specify your working directory]\fix_gss93subset.dat' / id 1-4 wrkstat 5 marital 6 agewed 7-8 sibs 9-10 childs 11 age 12-13. Always end your comment with a period. The command DATA LIST is to read a text format data file by assigning names and formats to each variable in the file. The keyword FIXED follows to tell SPSS that our data is a fixed format (actually, this is the SPSS default so you can skip it). The command FILE = “file location/name here” specifies your fixed format file and its location. After the slash (/) we provide SPSS with variable definitions (the variable names and column numbers) from the codebook. Two syntax rules you must remember here: 1. Notice that the whole command ended with a period (“.”). In SPSS, each command in SPSS must be completed with a period “.”. 2. SPSS Syntax is NOT case-sensitive. 7
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有