Calcite | Level 5

## array

hi, i have a data  in Celsius, it need to convert into Fahrenheit, please help me in executing this code

``````whats wrong with this code?

data want;
set have;
array celsius(9)TmpNeg10 TempNeg5 Temp0 Temp5 Temp10 Temp15 Temp20 Temp25 Temp30;
array fahrenheit(9);
do i = 1 to 9;
fahrenheit(i) = ((9/5)*(i) + 32);
end;
run;
proc  print;
run;``````

```Obs TmpNeg10 TempNeg5 Temp0 Temp5 Temp10 Temp15 Temp20 Temp25 Temp30
1 -20 -14 -10 -2 3 8 12 17 26
2 -26 -20 -15 -7 -2 4 8 13 22
3 -30 -24 -18 -10 -5 1 5 11 20
4 -33 -27 -21 -12 -7 -1 3 9 18
5 -35 -29 -23 -14 -9 -3 2 7 17
6 -37 -31 -25 -16 -10 -4 0 6 16
7 -39 -32 -26 -18 -12 -6 -1 5 15
8 -40 -34 -28 -19 -13 -7 -2 4 14 ```
1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: array

Kind of forgot the Celsius component:

```data want;
set have;
array celsius(9)TmpNeg10 TempNeg5 Temp0 Temp5 Temp10 Temp15 Temp20 Temp25 Temp30;
array fahrenheit(9);
do i = 1 to 9;
fahrenheit(i) = ((9/5)*Celsius(i) + 32);
end;
run;
proc  print;
run;```
4 REPLIES 4
Super User

## Re: array

Kind of forgot the Celsius component:

```data want;
set have;
array celsius(9)TmpNeg10 TempNeg5 Temp0 Temp5 Temp10 Temp15 Temp20 Temp25 Temp30;
array fahrenheit(9);
do i = 1 to 9;
fahrenheit(i) = ((9/5)*Celsius(i) + 32);
end;
run;
proc  print;
run;```
Calcite | Level 5

## Re: array

how could i even miss this. Anyways thank you
Super User

## Re: array

@Raj00007 wrote:
how could i even miss this. Anyways thank you

Arrays will allow use of other brackets than () for the index.

For ancient reasons I use [ ] for array indexes such as Celsius[i] . That way when I am using an index value I remind myself to use the array name as well.

I have found this somewhat helpful in long equations with multiple nested parentheses to help keep the levels straight as well.

Tourmaline | Level 20

## Re: array

> whats wrong with this code?