Solved
Contributor
Posts: 60

STD problem

Hi, I am trying to calculate the standard deviation of follow variables:

data sample;

set EVA_Inv.sample_v1;

array a CFO_ta Sales_Ta Inv_Total;

array b std_CFO std_Sales std_Inv;

do i=1 to dim(a);

b(i)=std(a(i),lag(a(i)),lag2(a(i)));

end;

std_cfo1=std(CFO_ta,lag(CFO_ta),lag2(CFO_ta));

run;

well, it seems "std_cfo1" get result, yet all b(i) return missing value.

What's the problem?

Anyone can please tell me? THX!

Accepted Solutions
Solution
‎12-05-2011 10:42 PM
Super User
Posts: 10,787

STD problem

I tested it. No problem.

```data sample;
set sashelp.class;
array a{*} age weight height;
array b{*} _age _weight _height;
do i=1 to dim(a);
b{i}=std(a{i},lag(a{i}),lag2(a{i}));
end;
run;

```

Ksharp

All Replies
Solution
‎12-05-2011 10:42 PM
Super User
Posts: 10,787

STD problem

I tested it. No problem.

```data sample;
set sashelp.class;
array a{*} age weight height;
array b{*} _age _weight _height;
do i=1 to dim(a);
b{i}=std(a{i},lag(a{i}),lag2(a{i}));
end;
run;

```

Ksharp

Contributor
Posts: 60

Re: STD problem

Yes, I test your code,you are right!

Well, I just check the code again and find I missed sth.

now I get it.

THX!

🔒 This topic is solved and locked.