tutor2

# tutor2 - THE UNIVERSITY OF HONG KONG DEPARTMENT OF...

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: THE UNIVERSITY OF HONG KONG DEPARTMENT OF STATISTICS AND ACTUARJAL SCIENCE STAT 1303 Data hilanagement Tutorial 2 Reading Data &: IVIodify Dataset I. Beiov»r is a portion of a. data step: data bmi; <statements>; datalines; ’ 1 101.7 178 2 97.1 170 3 114.2 191 4 101.9 179 5 93.1 182 6 108.1 177 7 85.0 184 8 89.1 182 9 95.8 179 10 97.8 183 11 78.7 . 12 77.5 172 run; These are data. for 12 subjects and each subject has subject number, weight in KC, height in GM. Write SAS statements to read the data for these 12 sub— jects. For eachE compute the body mass index (body mass index is the ratio of the weight in KC to the square of the height in meters). The ﬁnal data set Bh-‘ﬂ should have 4 variahies: subject ID. weight. height, body mass index. '2. There is a data. set named popQEdat. It contains the following data: Column Date 1—3 area. code. 4 gender 5—54 5 populations separated by spaces Notice that there are 2 lines of data for each area and the populations have embedded COMMA—S. (a) Reading the given data. set. (b) White a. SAS program to construct a new data set, which include the variable total (the total munber of population in each area according to the gender). Then compute the total number of population in each area. 3. Enter and submit the following program. data ex; input id 53 x1 x2; cards; A 1 2 3 3 4 B 2 3 run; proc print data=ex; run; a. Explore the Log. Any notes? Any error messages? b. Explore the Output. What is the output? c. Explore the WORK library. What is stored in the library? (1. Save the Log to a ﬁle ‘EX.LOG’, the Output to a ﬁle ‘EX.LST’, the SAS program to a ﬁle ‘EX.SAS’. 6. End and restart SAS. Open the ﬁle ‘EX.SAS’. Before submitting the program, are there any messages in Log, any output in Output, any ﬁles in WORK library? Submit the program and check again. f. Start a new Editor window and enter the following program. What do you expect in the output after the program has been submitted? Submit the program and check if it is What you expect. Save the program in a ﬁle ‘EX_1.SAS’. proc contents data=ex; run; g. Start a new Editor window and enter the following program. What do you expect in the output after the program has been submitted? Submit the program and check if it is what you expect. Save the program in a ﬁle ‘EX_2.SAS’ h. End and restart SAS. Open the ﬁle ‘EXﬁl .SAS’. What do you expect in the output after the program has been submitted? Submit the program and check if it is what you expect. What does the Log tell you? What will you do to generate the proper output? 4. Enter and submit the following program. libname mylib 'd:\'; data mylibex; input id 5’5 x1 x2; cards; A 1 2 3 3 4 B 2 3 run; a. What is the difference between this program and that in Q1? Explore the libraries and ﬁnd the physical ﬁles to verify. b. End and restart SAS. Enter the following program. What does this program do? Submit the program and explore the libraries to verify. libname thislib 'd:\'; 0. Write a SAS program to list out all the observations in the data set EX. The output should have a title ‘SAS exercise 5. Submit the SAS program data example; input subject gender \$ examl exam2 hw_grade S; final=(exml + exam2)/2; cards; 10 M 80 84 A 7 M 85 89 A 4 F 90 86 B; pro print ; title "Roster in student number order”; id subject; var examl exam2 final hw_grade; run; a. Referring to the notes, errors and warnings in the log window, identify the problems of the program and suggest correction methods. b. Correct the program. Note that you do not need to understand the program and you may need to search the help function for correcting the program. ...
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

tutor2 - THE UNIVERSITY OF HONG KONG DEPARTMENT OF...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online