// //outlook function //This founction extracts value of assinged variable name on some condition from file.. // //Syntax This function allows num of variable argument. outlook(filename,varialbe1,value1,,,variableN,valuen,last_variable); filename :extract value from filename. variable1,value1`variableN,valueN : conditions (variable name = value) last_variable :extraced value is at colum of last_variable name //(Quation1) //Line number variable '#' is allowed as variable name //(Quotion2) //If there are Plural values to be extracted on the assigned condition,first one is extracted. // //Example 1 //Reference by outlook // hand currency fxrate/ USD 99.8 AUD 92.4 NZD 86.6 EUR 92.5 JPY 1.0 ; put fxrate; hand currency amount/ JPY 2000 USD 380 AUD 420 ;`//convert amount to value by fx rate of the currency. value = amount * outlook(fxrate,"currency",currency,"fxrate");`

`//View amount and value of each currency. plot bar amount value by currency;`

`// //Example 2 //Generate normal distribution which has same covariance with original data. // //Read data as original covariance. get school.csv@;`

`//Get correlation for input of cholesky factarization. corr x1 x2 y;`

`//Get output corration and save tempolary file to check comparing with generated data. get freq@ana; put f_corr; //Execution cholesky factarization by input of correlation. chole x1 x2 y;`

`//Get output cholesky matrix and save tempolary file to use outlook function as below. get freq@ana; put f_chole; //Get average and standard devietaion by statis command to use outlook function as below. get school.csv@; statis x1 x2 y;`

`//Save average and std. to tempolary file. get freq@ana; put f_stat; // //Generate normal distibution which has same average and std,covariance of school.csv. // //Declare data clear and vector to use as below. clear; vector x[3]; vector ch[3][3]; vector sum[3]; //Generate 500 records which is normal distribution by loop. for(i=1;i<=500;i++) { //Get average and std from file by outlook function. x1m=outlook(f_stat,"_items_","AVERAGE","x1"); x1v=outlook(f_stat,"_items_","STD","x1"); x2m=outlook(f_stat,"_items_","AVERAGE","x2"); x2v=outlook(f_stat,"_items_","STD","x2"); ym=outlook(f_stat,"_items_","AVERAGE","y"); yv=outlook(f_stat,"_items_","STD","y"); //Generate 3 normal distoribution. x[1]=ranstd(x1m,x1v); x[2]=ranstd(x2m,x2v); x[3]=ranstd(ym,yv); //Make cholesky matrix from file by outlook function. ch[1][1]=outlook(f_chole,"#",1,"x1"); ch[1][2]=outlook(f_chole,"#",1,"x2"); ch[1][3]=outlook(f_chole,"#",1,"y"); ch[2][1]=outlook(f_chole,"#",2,"x1"); ch[2][2]=outlook(f_chole,"#",2,"x2"); ch[2][3]=outlook(f_chole,"#",2,"y"); ch[3][1]=outlook(f_chole,"#",3,"x1"); ch[3][2]=outlook(f_chole,"#",3,"x2"); ch[3][3]=outlook(f_chole,"#",3,"y"); //Set covariance to normal distribution. for(j=1;j<=3;j++) { sum[j]=0; for(k=1;k<=3;k++) { sum[j]=sum[j]+ch[j][k]*x[k]; } } x1r=sum[1]; x2r=sum[2]; yr =sum[3]; //Output earch reacord. outrec; }`

`//View Genaration of normal distribution which may be same distoribution of school.csv. plot scat x1r x2r yr;`

`//Check same correlation comparing generated data with original school.csv data corr x1r x2r yr;`

```
```