Result database connection HP_Omistaja 9. maata 2008 10:42 jtue 25. maata 2008 15:33 56,24 1,0,0,1,1,1,0,,0, 1,652,102,550,376,17 Arial, 15 0,Linkmodule Result_database_conn,2,2,0,1,C:\temp\Transferring_to_result_database.ANA Concatenation UDFs This library contains functions to make various instances of concatenation more convenient. Concat3 thru Concat10 are generalizations of the built-in Concat function which concatenate from 3 to 10 arrays in a single call (while the built-in Concat concatenates two arrays). ConcatRows concatenates all the rows of a single array. David Kendall & Lonnie Chrisman Mon, Jan 26, 2004 8:49 AM Lonnie Wed, Sep 05, 2007 3:23 PM 48,24 104,216,1 68,24 1,0,0,1,1,1,0,0,0,0 1,39,36,798,452,23 (A1, A2, A3: ArrayType; I1, I2, I3, J: IndexType ) Concat3 Concatenates three arrays, A1, A2, and A3. I1, I2, and I3 are the indexes that are joined; J is the index of the new array; J usually is the concatenation of I1, I2, and I3 Index I12 := Concat(I1,I2); Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, J ) 88,64,1 48,26 2,56,56,986,596 A1,A2,A3,I1,I2,I3,J (A1, A2, A3, A4: ArrayType; I1, I2, I3, I4, J: IndexType ) Concat4 Concatenates four arrays, A1, A2, A3, and A4. I1, I2, I3, and I4 are the indexes that are joined; J is the index of the new array; J usually is the concatenation of I1, I2, I3, and I4. Index I12 := Concat(I1,I2); Index I123:= Concat(I12, I3); Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, J); 192,64,1 48,24 2,30,30,986,596 A1,A2,A3,A4,I1,I2,I3,I4,J 0 (A1, A2, A3, A4, A5, A6, A7, A8, A9: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, I9, J: IndexType) Concat9 Concatenates nine arrays, A1, ..., A9. I1, ..., I9 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I9. Index I12 := Concat(I1,I2); Index I123 := Concat(I12, I3); Index I1234 := Concat(I123, I4); Index I12345 := Concat(I1234, I5); Index I123456 := Concat(I12345, I6); Index I1234567 := Concat(I123456, I7); Index I12345678 := Concat(I1234567, I8); Concat( Concat( Concat( Concat( Concat( Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, I1234), A5, I1234, I5, I12345), A6, I12345, I6, I123456), A7, I123456, I7, I1234567), A8, I1234567, I8, I12345678), A9, I12345678, I9, J); 88,232,1 48,24 2,27,120,469,638 A1,A2,A3,A4,A5,A6,A7,A8,A9,I1,I2,I3,I4,I5,I6,I7,I8,I9,J 0 (A1, A2, A3, A4, A5: ArrayType; I1, I2, I3, I4, I5, J: IndexType ) Concat5 Concatenates five arrays, A1, ..., A5. I1, ..., I5 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I5. Index I12 := Concat(I1,I2); Index I123:= Concat(I12, I3); Index I1234 := Concat(I123, I4); Concat( Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, I1234), A5, I1234, I5, J); 88,120,1 48,24 2,160,160,986,596 A1,A2,A3,A4,A5,I1,I2,I3,I4,I5,J (A1, A2, A3, A4, A5, A6: ArrayType; I1, I2, I3, I4, I5, I6, J: IndexType ) Concat6 Concatenates six arrays, A1, ..., A6. I1, ..., I6 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I6. Index I12 := Concat(I1,I2); Index I123:= Concat(I12, I3); Index I1234 := Concat(I123, I4); Index I12345 := Concat(I1234, I5); Concat( Concat( Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, I1234), A5, I1234, I5, I12345), A6, I12345, I6, J); 192,120,1 48,24 2,644,94,602,712 A1,A2,A3,A4,A5,A6,I1,I2,I3,I4,I5,I6,J 0 (A1, A2, A3, A4, A5, A6, A7: ArrayType; I1, I2, I3, I4, I5, I6, I7, J: IndexType ) Concat7 Concatenates seven arrays, A1, ..., A7. I1, ..., I7 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I7. Index I12 := Concat(I1,I2); Index I123:= Concat(I12, I3); Index I1234 := Concat(I123, I4); Index I12345 := Concat(I1234, I5); Index I123456 := Concat(I12345, I6); Concat( Concat( Concat( Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, I1234), A5, I1234, I5, I12345), A6, I12345, I6, I123456), A7, I123456, I7, J); 88,176,1 48,24 2,580,98,551,565 A1,A2,A3,A4,A5,A6,A7,I1,I2,I3,I4,I5,I6,I7,J (A1, A2, A3, A4, A5, A6, A7, A8: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, J: IndexType ) Concat8 Concatenates eight arrays, A1, ..., A8. I1, ..., I8 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I8. Index I12 := Concat(I1,I2); Index I123:= Concat(I12, I3); Index I1234 := Concat(I123, I4); Index I12345 := Concat(I1234, I5); Index I123456 := Concat(I12345, I6); Index I1234567 := Concat(I123456, I7); Concat( Concat( Concat( Concat( Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, I1234), A5, I1234, I5, I12345), A6, I12345, I6, I123456), A7, I123456, I7, I1234567), A8, I1234567, I8, J); 192,176,1 48,24 2,12,98,561,737 A1,A2,A3,A4,A5,A6,A7,A8,I1,I2,I3,I4,I5,I6,I7,I8,J 0 (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, J: IndexType) Concat10 Concatenates ten arrays, A1, ..., A10. I1, ..., I10 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I10. Index I12 := Concat(I1,I2); Index I123 := Concat(I12, I3); Index I1234 := Concat(I123, I4); Index I12345 := Concat(I1234, I5); Index I123456 := Concat(I12345, I6); Index I1234567 := Concat(I123456, I7); Index I12345678 := Concat(I1234567, I8); Index I123456789 := Concat(I12345678, I9); Concat( Concat( Concat( Concat( Concat( Concat( Concat( Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, I123), A4, I123, I4, I1234), A5, I1234, I5, I12345), A6, I12345, I6, I123456), A7, I123456, I7, I1234567), A8, I1234567, I8, I12345678), A9, I12345678, I9, I123456789), A10, I123456789, I10, J); 192,232,1 48,24 2,542,93,632,744 A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,J 0 (A : ArrayType ; RowIndex,ColIndex,ResultIndex : IndexType) ConcatRows (A,I,J,K) Takes an array, A indexed by RowIndex & ColIndex, and concatenates each row, henceforth flattening the array by one dimension. The result is indexed by ResultIndex, which must be an index with size(RowIndex) * size(ColIndex) elements. index L := [ identifier of RowIndex, identifier of ColIndex, "val"]; slice(Mdarraytotable(A,ResultIndex,L),L,3) 320,64,1 64,24 2,30,320,478,348 A,RowIndex,ColIndex,ResultIndex Location cardinality 26 96,144,1 48,24 [Formnode Result_id_cardinal1] , Var for rdb mortality_rate1 96,88,1 48,24 1,1,1,1,1,1,0,0,0,0 2,729,296,416,303,0,MIDM [Cause_of_death,Alternative_strategi] [Cause_of_death,Alternative_strategi] [Sys_localindex('I'),1,Sys_localindex('F'),1,Sys_localindex('G'),1] Result table var a:=sample(Var_for_rdb); index col:= ['Result_id','Var_id','Result','Sample']; index endscen:= 1+Location_cardinality..size(Var_for_rdb)+Location_cardinality; index row:= 1..size(endscen)*size(run); index l:= concat(indexnames(Var_for_rdb),['Value']); a:= mdarraytotable(a,endscen,l); a:= a[.l='Value']; a:= if col='Result' then a else 0; a:= if col='Sample' then run else a; a:= if col='Result_id' then endscen else a; a:= if col='Var_id' then Variable_cardinality+1 else a; a:= concatrows(a,endscen,run,row) 216,88,1 48,24 2,688,435,528,319 2,790,43,395,769,0,MIDM [Sys_localindex('COL'),Sys_localindex('ROW')] [Sys_localindex('COL'),2,Sys_localindex('ENDSCEN'),1,Run,2] Location table var a:=mid(Var_for_rdb); index col:= ['Result_id','Dim_id','Location']; var h:= indexnames(a); index l:= concat(h,['Value']); index row:= 1..size(a)*size(h); var f:= size(h)+1-ceil(row/size(a)); var e:= if col='Dim_id' then slice(h,f); var g:= min((if e[.col='Dim_id']=l then row else 1G),row); index endscen:= 1+Location_cardinality..size(a)+Location_cardinality; a:= mdarraytotable(a,endscen,l); for y:= row do ( var c:= g[l=e[col='Dim_id',row=y]]; e:= if col='Result_id' then y+1-c+Location_cardinality else e; c:= a[endscen=y+1-c+Location_cardinality]; c:= c[l=e[col='Dim_id']]; e:= if col='Location' then c else e ) 216,144,1 48,24 2,392,450,476,319 2,27,221,398,584,0,MIDM [Sys_localindex('COL'),Sys_localindex('ROW')] [1441,961,481,1] Result_id cardinal 0 392,40,1 124,13 1,0,0,1,0,0,0,72,0,1 Location_cardinality Loc2 Var a:= Location_table; if a.col='Dim_id' then subindex(Dim3, a[.col='Dim_id'], Dim3) else a 328,144,1 48,24 2,55,338,416,416,0,MIDM [Sys_localindex('COL'),Sys_localindex('ROW')] Variable cardinality 7 96,32,1 48,24 1,1,1,1,1,1,0,0,0,0 [Formnode Var_id1] Var_id 0 392,16,1 124,13 1,0,0,1,0,0,0,72,0,1 Variable_cardinality Dim3 Table(Self)( 'Decision foor food healthiness','Health_effect','Year','Cause_of_death') [1,2,3,4] 328,216,1 48,24 Functions for Analytica - wiki conversion 464,104,1 60,36 (a:prob) Stats index statistics:= ['Mean','SD','0.01','0.025','0.05','0.25','0.5 (Median)','0.75','0.95','0.975','0.99']; a:= array(statistics,[mean(a), sdeviation(a), getfract(a,0.01), getfract(a,0.025), getfract(a,0.05), getfract(a,0.25), getfract(a,0.5), getfract(a,0.75), getfract(a,0.95), getfract(a,0.975), getfract(a,0.99)]); round(a*10)/10&'' 96,48,1 48,24 2,102,90,476,478 a