Obsidian | Level 7

## small optimization problem

Hello
I have a small optimization problem.
I have two series of data and I would like to optimize the differences between them.

I could use a loop but I know that sas has optimizing functions but I do not know it.

Maybe someone will help me.

The problem looks as follows.

``````data test;
input n \$ x \$ y;
datalines;
1	1	1
2	0.534825871	0.390243902
3	0.667910448	0.609756098
4	0.140547264	0.048780488
5	0.237562189	0.195121951
6	0	0
7	0.630597015	0.048780488

;
run;

data test;
set test;
z = abs(x - y);
sum_z = ( z + lag1(z) + lag2(z) + lag3(z) + lag4(z) + lag5(z) + lag6(z) );
run;

data test;
set test;
z1 = abs(x - (y + 0.01));
sum_z1 = ( z1 + lag1(z1) + lag2(z1) + lag3(z1) + lag4(z1) + lag5(z1) + lag6(z1) );
run;

data test;
set test;
z2 = abs(x - (y + 0.02));
sum_z2 = ( z2 + lag1(z2) + lag2(z2) + lag3(z2) + lag4(z2) + lag5(z2) + lag6(z2) );
run;
/*******
********
*******/
data test;
set test;
z6 = abs(x - (y + 0.06));
sum_z6 = ( z6 + lag1(z6) + lag2(z6) + lag3(z6) + lag4(z6) + lag5(z6) + lag6(z6) );
run;``````

optimize the differences between x and y -> the differences are presented (example) in the variable sum_z to sum_z6

Tourmaline | Level 20

## Re: small optimization problem

What exactly are you trying to optimize?

Can you be a bit more specific in your explanation?

Discussion stats