This program creates a dataset named TEMPERATURE by reading raw values via DATALINES. It uses two arrays: one for Fahrenheit temperatures (TF1-TF10) and the other for storing Celsius conversions (TC1-TC10). A DO loop iterates over these arrays to apply the conversion formula. The result is then displayed in the output report.
Data Analysis
Type : CREATION_INTERNE
Data is included directly in the source code via the DATALINES statement.
1 Code Block
DATA STEP Data
Explanation : DATA step that reads 10 Fahrenheit temperature values per line, declares two arrays to manipulate columns in an indexed manner, and calculates the corresponding Celsius values.
Copied!
data TEMPERATURE;
input TF1-TF10;
array TF[10];
array TC[10];
do count = 1 to 10;
TC[count]=5/9*(TF[count]-32);
end;
drop count;
datalines;
32 212 -40 10 20 30 40 50 60 70
-10 0 10 20 30 40 50 60 70 80
;
1
DATA TEMPERATURE;
2
INPUT TF1-TF10;
3
array TF[10];
4
array TC[10];
5
DO count = 1 to 10;
6
TC[count]=5/9*(TF[count]-32);
7
END;
8
drop count;
9
10
DATALINES;
11
32212 -4010203040506070
12
-10 0 1020304050607080
13
;
2 Code Block
PROC PRINT
Explanation : Standard print procedure to view the content of the previously created TEMPERATURE table.
Copied!
proc print;
title 'Problem 15.2 Listing of Data Set TEMPERATURE';
run;
1
2
PROC PRINT;
3
title 'Problem 15.2 Listing of
4
Data Set TEMPERATURE';
5
RUN;
6
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.