/*NELS DATA EXTRACTOR 1.1 FOR N2P data*/ /*Written by Kazuaki Uekawa, Ph.D. SAS Independent Consultant ueka@src.uchicago.edu*/ /*http://www.src.uchicago.edu/users/ueka*/ /*purpose*/ /*This program allows you select variables by typing in names instead of clicking on ECB.*/ /*typing in names is faster than clicking*/ /*Also, with this program it is easy to switch N2P and N4P, depending on which data sets you need to use. With ECB, this would be a very time-consuming task.*/ /*make sure that you have the following in the same working directory*/ /* N4Palltext.TXT N2Palltext.TXT Also install NELS eletric code book, the version that was most update in the year 2002. I think it was a 1998 release. Information is available from National Center for Education Statistics. The data of the earlier ECB had different structures, so won't work with this program. */ /*specify the working directory*/ %let folder =C:\ECBW\N2P; /*if you are using BY, F1, F2, and F3 data sets --> %let whichfile=N3P; */ /*if you are using BY, F1, F2 data sets but not F3 data (in other words if your outcome variable is of 10th grader) --> %let whichfile=N2P; */ %let whichfile=N2P; /*DIRECTION a) type in the name of variables that you like like the following --where you see (each line contains ...) (eachline contains "VARIABLENAME1" or eachline contains "VARIABLENAME2" or eachline contains "VARIABLENAME3"); You can put as many "eachline contains "XXX" or" as you like. Type in capital. b) Run this SAS program, which produces a file "extractN2P.tag" or "extractN4P.tag." They are tag files. Import the tag file into Electric codebook by first opening up ECB (there are two ECBs, one for NP2 and one for NP4) and by going to FILE-->IMPORT TAG FILES-->BROWSE (and find the file). You also get a file in which you see variable names and labels. The name of the file is describeN2P.txt or describeN4P.txt. c) Then go to FILE --> OUTPUT-->SAS-PC (or SPSS) to kick out a SAS (or SPSS) program file, which creates the data set*/ options pagesize=58 linesize=78 pagesize=32767; libname here "&folder"; filename N2P "&folder\N2Palltext.TXT"; filename N4P "&folder\N4Palltext.TXT"; data two ;infile &whichfile length=lg;input @;input @1 eachline $varying78. lg; data three;set two; where eachline contains "Variable[" and (eachline contains "BYS43" or eachline contains "F1S77"); jun=_n_; number=substr(eachline,10,6); varname=substr(eachline,20,9); description=substr(eachline,30,40); proc print data=three; *where jun <100; var number varname description; run; data four;set three; file "&folder\extract&whichfile..tag"; put (number) (10.0); run; data four;set three; file "&folder\describe&whichfile..txt"; put (varname)(10.0) (description) (40.0); run;