Use of INFILE statement to read an external data file which has .DAT extension H
ID: 3041310 • Letter: U
Question
Use of INFILE statement to read an external data file which has .DAT extension
Here is the information from the DAT File:
1. 1 8 21 0 2 1 10 20 0 3 1 12 21.5 0 4 1 14 23 0 5 2 8 21 0 6 2 10 21.5 0
7 2 12 24 0 8 2 14 25.5 0 9 3 8 20.5 0 10 3 10 24 0 11 3 12 24.5 0 12 3
14 26 0 13 4 8 23.5 0 14 4 10 24.5 0 15 4 12 25 0 16 4 14 26.5 0 17 5 8
21.5 0 18 5 10 23 0 19 5 12 22.5 0 20 5 14 23.5 0 21 6 8 20 0 22 6 10
21 0 23 6 12 21 0 24 6 14 22.5 0 25 7 8 21.5 0 26 7 10 22.5 0 27 7 12
23 0 28 7 14 25 0 29 8 8 23 0 30 8 10 23 0 31 8 12 23.5 0 32 8 14 24 0
33 9 8 20 0 34 9 10 21 0 35 9 12 22 0 36 9 14 21.5 0 37 10 8 16.5 0 38
10 10 19 0 39 10 12 19 0 40 10 14 19.5 0 41 11 8 24.5 0 42 11 10 25 0
43 11 12 28 0 44 11 14 28 0 45 12 8 26 1 46 12 10 25 1 47 12 12 29 1 48
12 14 31 1 49 13 8 21.5 1 50 13 10 22.5 1 51 13 12 23 1 52 13 14 26.5 1
53 14 8 23 1 54 14 10 22.5 1 55 14 12 24 1 56 14 14 27.5 1 57 15 8 25.5
1 58 15 10 27.5 1 59 15 12 26.5 1 60 15 14 27 1 61 16 8 20 1 62 16 10
23.5 1 63 16 12 22.5 1 64 16 14 26 1 65 17 8 24.5 1 66 17 10 25.5 1 67
17 12 27 1 68 17 14 28.5 1 69 18 8 22 1 70 18 10 22 1 71 18 12 24.5 1
72 18 14 26.5 1 73 19 8 24 1 74 19 10 21.5 1 75 19 12 24.5 1 76 19 14
25.5 1 77 20 8 23 1 78 20 10 20.5 1 79 20 12 31 1 80 20 14 26 1 81 21 8
27.5 1 82 21 10 28 1 83 21 12 31 1 84 21 14 31.5 1 85 22 8 23 1 86 22
10 23 1 87 22 12 23.5 1 88 22 14 25 1 89 23 8 21.5 1 90 23 10 23.5 1 91
23 12 24 1 92 23 14 28 1 93 24 8 17 1 94 24 10 24.5 1 95 24 12 26 1 96
24 14 29.5 1 97 25 8 22.5 1 98 25 10 25.5 1 99 25 12 25.5 1 100 25 14
26 1 101 26 8 23 1 102 26 10 24.5 1 103 26 12 26 1 104 26 14 30 1 105
27 8 22 1 106 27 10 21.5 1 107 27 12 23.5 1 108 27 14 25 1 109 28 16 28
0 110 28 13 26 1 111 28 18 25 0 112 28 17.5 22 1
Note that multiple records are on the same data line (You can open this using Notepad to see how the data is entered into this file). Keep in mind the use of @@ symbol to read multiple records entered on the same data line.
There are five variables: ID, GROUP AGE, SCORE and GENDER.
Perform the following tasks:
Use the INFILE statement in your SAS program to read the external data file, and create a temporary SAS data file.
Sort the data set by the variable, GENDER
Compute the mean, standard deviation, standard error, minimum, and maximum for the variable, SCORE, by GENDER. Restrict the number of decimal places to 2 in your answer.
.Submission: Submit the SAS program as a SAS program file
Explanation / Answer
data test;
infile cards dsd;
input ID GROUP_AGE SCORE GENDER @@;
cards;
1 8 21 0 2 1 10 20 0 3 1 12 21.5 0 4 1 14 23 0 5 2 8 21 0 6 2 10 21.5 0
7 2 12 24 0 8 2 14 25.5 0 9 3 8 20.5 0 10 3 10 24 0 11 3 12 24.5 0 12 3
14 26 0 13 4 8 23.5 0 14 4 10 24.5 0 15 4 12 25 0 16 4 14 26.5 0 17 5 8
21.5 0 18 5 10 23 0 19 5 12 22.5 0 20 5 14 23.5 0 21 6 8 20 0 22 6 10
21 0 23 6 12 21 0 24 6 14 22.5 0 25 7 8 21.5 0 26 7 10 22.5 0 27 7 12
23 0 28 7 14 25 0 29 8 8 23 0 30 8 10 23 0 31 8 12 23.5 0 32 8 14 24 0
33 9 8 20 0 34 9 10 21 0 35 9 12 22 0 36 9 14 21.5 0 37 10 8 16.5 0 38
10 10 19 0 39 10 12 19 0 40 10 14 19.5 0 41 11 8 24.5 0 42 11 10 25 0
43 11 12 28 0 44 11 14 28 0 45 12 8 26 1 46 12 10 25 1 47 12 12 29 1 48
12 14 31 1 49 13 8 21.5 1 50 13 10 22.5 1 51 13 12 23 1 52 13 14 26.5 1
53 14 8 23 1 54 14 10 22.5 1 55 14 12 24 1 56 14 14 27.5 1 57 15 8 25.5
1 58 15 10 27.5 1 59 15 12 26.5 1 60 15 14 27 1 61 16 8 20 1 62 16 10
23.5 1 63 16 12 22.5 1 64 16 14 26 1 65 17 8 24.5 1 66 17 10 25.5 1 67
17 12 27 1 68 17 14 28.5 1 69 18 8 22 1 70 18 10 22 1 71 18 12 24.5 1
72 18 14 26.5 1 73 19 8 24 1 74 19 10 21.5 1 75 19 12 24.5 1 76 19 14
25.5 1 77 20 8 23 1 78 20 10 20.5 1 79 20 12 31 1 80 20 14 26 1 81 21 8
27.5 1 82 21 10 28 1 83 21 12 31 1 84 21 14 31.5 1 85 22 8 23 1 86 22
10 23 1 87 22 12 23.5 1 88 22 14 25 1 89 23 8 21.5 1 90 23 10 23.5 1 91
23 12 24 1 92 23 14 28 1 93 24 8 17 1 94 24 10 24.5 1 95 24 12 26 1 96
24 14 29.5 1 97 25 8 22.5 1 98 25 10 25.5 1 99 25 12 25.5 1 100 25 14
26 1 101 26 8 23 1 102 26 10 24.5 1 103 26 12 26 1 104 26 14 30 1 105
27 8 22 1 106 27 10 21.5 1 107 27 12 23.5 1 108 27 14 25 1 109 28 16 28
0 110 28 13 26 1 111 28 18 25 0 112 28 17.5 22 1
;run;
/*Sort the data set by the variable, GENDER*/
proc sort data=test;
by GENDER;
run;
/*compute the mean, standard deviation, standard error, minimum, and maximum for the variable, SCORE, by GENDER. Restrict the number of decimal places to 2 in your answer
.Submission: Submit the SAS program as a SAS program file*/
proc means data=test MEAN STD MIN MAX STDERR maxdec=2 ;
var score;
by gender;
OUTPUT OUT= calcstat MEAN STD STDERR MIN MAX ;
run;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.