Scramble social insurance numbers
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 | * Want to scramble sin numbers. DATA LIST LIST /sin(A11). BEGIN DATA. 12345678901 12345678901 12345678901 12345678901 12345678901 12345678901 12345678901 12345678901 12345678901 12345678901 END DATA. LIST. COMPUTE id=$casenum. SAVE OUTFILE='data.sav'. VECTOR rvar(11). LOOP #cnt=1 TO 11. - COMPUTE rvar(#cnt)=UNIFORM(1). END LOOP. LOOP #cnt = 1 to 11. - COMPUTE rvar = rvar(#cnt) . - XSAVE OUTFILE = 'temp.sav' / keep = id rvar. END LOOP. EXECUTE. GET FILE = 'temp.sav' . RANK VARIABLES= rvar (d) BY id /TIES = LOW / RANK INTO rvarrank . DO IF $casenum=1. - COMPUTE ind=0. ELSE. - COMPUTE ind=MOD(LAG(ind)+1,11). END IF. VECTOR rvar(11). COMPUTE rvar(ind+1) = rvarrank. EXECUTE. AGGREGATE OUTFILE = * /PRESORTED / BREAK = id /rvar1 TO rvar11 = MAX(rvar1 TO rvar11). MATCH FILES /FILE = 'data.sav' /FILE = * /BY id . EXECUTE. STRING sin2(A11). VECTOR rvar=rvar1 TO rvar11. COMPUTE sin2=SUBSTR(sin,rvar(1),1). LOOP #cnt=2 TO 11. - COMPUTE sin2=CONCAT(RTRIM(sin2),SUBSTR(sin,rvar(#cnt),1)). END LOOP. EXECUTE. |
Related pages
...