Run syntax on files whose names are derived from a data file
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | DATA LIST LIST /hnumb(F8) usedeal(F8) korting(F8) shoptr1(F8) wfk(F8). BEGIN DATA 202 2 2 5 110 202 1 3 5 110 202 3 2 2 3 END DATA. SAVE OUTFILE='c:\\data\\hh202pc2.sav'. DATA LIST LIST /hnumb(F8) usedeal(F8) korting(F8) shoptr1(F8) wfk(F8). BEGIN DATA 300 2 7 5 110 300 2 8 1 110 END DATA. SAVE OUTFILE='c:\\data\\hh300pc2.sav'. DATA LIST LIST /hnumb(F8) usedeal(F8) korting(F8) shoptr1(F8) wfk(F8). BEGIN DATA 509 2 75 1 110 509 2 75 1 110 509 2 75 1 0 END DATA. SAVE OUTFILE='c:\\data\\hh509pc2.sav'. * Define the file containing the house numbers to be studied. DATA LIST LIST /hnumb(F8). BEGIN DATA. 202 300 509 END DATA. LIST. SAVE OUTFILE='c:\\data\\hnumbers.sav'. *******. SET MPRINT=on. * Define a macro to do analysis on one house. * This is your syntax with the following changes 1. add a DEFINE line at the beginning 2. add an ENDDEFINE line at the end 3. add the 2 'let' command which define the file names 4. change the paths to fit your requirements (i used shorter path for testing purposes). Ray. *///////////////////////////////////////////////////////. DEFINE !do_job(hnumb=!TOKENS(1)) !LET !file1=!QUOTE(!CONCAT('C:\\DATA\\hh',!hnumb,'pc2.sav')). GET FILE=!file1. EXECUTE . IF (MISSING(usedeal) and korting >=0.05) usedeal=11. IF (MISSING(usedeal) and korting < 0.05) usedeal=5. EXECUTE. SAVE OUTFILE=!file1. FILTER OFF. USE ALL. SELECT IF(wfk=110). EXECUTE . IF (( missing(LAG(shoptr1))|(LAG(shoptr1)~=shoptr1)))record2=1. EXECUTE. !LET !file2=!QUOTE(!CONCAT('C:\\DATA\\resultaten\\hh',!hnumb,'pc2 4.sav')). SAVE OUTFILE=!file2 /KEEP=hnumb usedeal korting /COMPRESSED. !ENDDEFINE. *///////////////////////////////////////////////////////. *Now write syntax file which will call the above macro for each house number. GET FILE='C:\\data\\hnumbers.sav'. WRITE OUTFILE='C:\\data\\do the job.sps' / '!Do_job hnumb=' hnumb '.'. Execute. New file. * The next line does the full job. INCLUDE 'C:\\data\\do the job.sps'. |
Related pages
...