Include Several File-wise or Group-wise Statistics Into Syntax
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 | * The idea illustrated in this syntax is powerful and, hence, frequently used. * The objective is to define two macros which will contain some numerical values previously obtained from the data. * When the macros are subsequently used, the relevant numerical values are obtained. * Raynald Levesque rlevesque@videotron.ca. SET MPRINT=ON. DATA LIST LIST /id(F8) var1(F8). BEGIN DATA. 1 10 1 15 1 10 2 20 2 25 3 15 3 25 END DATA. LIST. SAVE OUTFILE='c:\\temp\\data.sav'. COMPUTE break_v=(id=1). AGGREGATE /OUTFILE=* /BREAK=break_v /var1_1 = SUM(var1). DO IF break_v=1. WRITE OUTFILE 'c:\\temp\\temp.sps' /"DEFINE !sum_1()"/var1_1/"!ENDDEFINE.". ELSE. WRITE OUTFILE 'c:\\temp\\temp.sps' /"DEFINE !sum_tot()"/var1_1/"!ENDDEFINE.". END IF. EXE. GET FILE='c:\\temp\\data.sav'. INCLUDE 'c:\\temp\\temp.sps'. *Now use the macros. * the sole purpose of the following compute is to show that the method works. DO IF id=1. COMPUTE var2 =!sum_1. ELSE. COMPUTE var2 = !sum_1/(!sum_1 + !sum_tot). END IF. FORMATS var2(F8.3). EXECUTE. |
Related pages
...