Read ASCII data variable name, value and value labels
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | * The value and value labels are in an ASCII file. Have to read them and apply the labels to a data file. * Raynald Levesque rlevesque@videotron.ca. NEW FILE. INPUT PROGRAM. * syntax assumes that if there is a blank is column 2 and that the line contains a variable name. DATA LIST FIXED /KIND 2-2(A). DO IF (kind EQ ' '). REREAD. DATA LIST /v_value 1-1(F) lab1 3-15(A). END CASE. ELSE. REREAD. DATA LIST /v_name 1-8(A). LEAVE v_name. END CASE. END IF. END INPUT PROGRAM. * This is the file which contains the value labels. BEGIN DATA var1 1 small 2 big var2 1 strong 2 weak 3 dont know var3 1 frequently 2 infrequently 4 once a week 6 once a month END DATA. LIST. SELECT IF ~MISSING(v_value). STRING q1(A1). COMPUTE q1='"'. SORT CASES BY v_name. MATCH FILES FILE=* /BY=v_name /FIRST=first. * ------- write a syntax file to assign the value labels. WRITE OUTFILE 'c:\\temp\\temp1.sps' /"ADD VALUE LABELS " v_name " " v_value " " q1 lab1 q1".". EXE. *Say this is your data file (without the labels); read it. NEW FILE. DATA LIST LIST /var1 var2 var3. BEGIN DATA 1 1 1 2 2 2 1 3 4 2 1 6 1 3 4 END DATA. LIST. * then apply the labels. INCLUDE 'c:\\temp\\temp1.sps'. * that's it!. |
Related pages
...