Read ASCII with comma and dot separated decimals
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 | * QUESTION: I am using SPSS v. 10.0.07 I would like to import data from ASCII file with GET DATA. For floating point data the decimals are separated by a comma. Eg data set test.dat V1 V2 350.00; 1,01 350.00; 2,01 0.00; 3,02 350.00; 4,03 * ANSWER posted to SPSSX-L by rlevesque@videotron.ca on 2001/07/04. DATA LIST FIXED /V1 1-80(A). BEGIN DATA 350.00; 1,01 350.00; 2,01 0.00; 3,02 350.00; 4,03 END DATA. LIST. LOOP IF INDEX(V1,",")>0. COMPUTE SUBSTR(V1, INDEX(V1,","),1)=".". END LOOP. WRITE OUTFILE='c:\\temp\\temp.txt' /V1. EXECUTE. DATA LIST FILE='c:\\temp\\temp.txt' LIST (";") /V1 V2. LIST. *%%%%%%%%%%%%%. * Alternative (simpler) method suggested by John Peck (peck@spss.com). DATA LIST FREE (";") /V1(COMMA8.2) v2(DOT8.2). BEGIN DATA 350.00; 1,01 350.00; 2,01 0.00; 3,02 350.00; 4,03 END DATA. LIST. |
Related pages
...