Final answer:
To convert temperatures from Fahrenheit to Celsius, the formula C = (F - 32) × (5/9) is used. In SAS, arrays are created for both the Fahrenheit and Celsius variables, and the conversion is applied to each temperature in a loop.
Step-by-step explanation:
To convert temperatures from the Fahrenheit scale to the Celsius scale and create a new SAS dataset Temper2 with variables C1-C30, you'll need to apply the conversion formula. The formula to convert Fahrenheit to Celsius is C = (F - 32) × (5/9). Each degree on the Fahrenheit scale is smaller than a degree on the Celsius scale since one degree Celsius is equivalent to 1.8 degrees Fahrenheit.
Here's how you could write a SAS program to create the new dataset:
data Temper2;
set Temper;
array F_Array[30] F1-F30; /* This array represents the Fahrenheit temperatures in the dataset Temper */
array C_Array[30] C1-C30; /* This will be the new Celsius temperatures array in the dataset Temper2 */
do i = 1 to 30;
C_Array[i] = (F_Array[i] - 32) × (5/9); /* Conversion formula applied to each temperature */
end;
drop i F1-F30; /* Drop the Fahrenheit variables and the counter 'i' from the new dataset */
run;
In this code, an array for the original Fahrenheit variables and a new array for the Celsius variables are declared. The conversion formula is then applied to each Fahrenheit temperature, and the results are stored in the new Celsius variables. Lastly, the original Fahrenheit variables and index variable i are dropped from Temper2.