Question: Stat 6 6 0 5 : SAS Programming Final Exam Due Date: 0 4 / 3 0 / 2 0 2 4 Please Note: 1

Stat 6605: SAS Programming
Final Exam
Due Date: 04/30/2024
Please Note:
1. Write your name in your program using a comment statement.
2. Assign a title with the problem number for each problem,
3. Your output for each problem should contain only what is asked.
4. Please submit your programs and outputs.
Problems:
1. Given the set of numbers: 11,23,17,39,50, using the array to find averages of any two numbers from a set of numbers. The two numbers can be the same.
.
2. Given the data set, using array to change all zeros to missing.
data dd;
input x name $ address $ mm cc di $ kk;
cards;
8 aa klkk 0456012
0 bb lkj 12920
0 ddd and 0051
;
Run;
3. What, if anything, is wrong with the following programs? An ellipsis (...) indicates proportions of a statement that are not germane to the exercise.
a. data p1; set mast;
if sector =a4 then output;
data p2; set me;
if sector =29 then output;
data sects;
merge p1 p2;
by sector;
b. data one; infile ... ;
length type 2;
input lab grp m1-m50;
run;
data two; infile ... ;
input lab grp type mx1-mx10;
run;
data merge;
merge two one;
by lab grp;
run;
4. What, if anything, is wrong with the following programs?
a. data new; update one two three; by id;
b. data new; update transact master; by id;
5. Refer to the data
data demog;
input id contry $ 5-17 pop 19-22 pcturb 24-25 energy 27-29 cult 31-32
pasture 34-35 forest 37-38;
cards;
101 China 10623219113014
107 Japan 1227611113268
113 Philippines 6240938440
102 India 80025751421
112 Vietnam 6219420140
109 Bangladesh 107.....
105 Indonesia 175.....
110 Paskistan 1052862564
304 United States 24374280202628
311 Mexico 827050133823
406 Brazil 141711991966
508 Nigeria 109287342316
603 USSR 28465176101742
614 West Germany 6185163301929
615 Italy 577290411621
;
run;
and format:
proc format;
value cont 100-199='Asia' 200-299='Australasia'
300-399='N. America' 400-499='S. America'
500-599='Africa' 600-699='Europe';
Run;
a. Write chart procedure statements to produce a vertical bar chart of average energy consumption by country grouped into continent. Use the cont format to recode country number into continent name. What would the chart look like if the format were not used?
b. How would you rewrite the cont format to arrange the bars in alphabetical order? You could accomplish this by using a chart statement.
6. What, if anything, is wrong with the following assignment statements?
a. xt=02/feb/80d;
b. baseline=d22apr90;
c. st=12mar58;
7. Variable zipcode is read with format$10. It reads zip codes in the form 07417 or 07417-1280. Create variable_9digit. It equals 1 if zipcode has a hyphen separating the fifth and seven digits. Otherwise it equals 0. Write the statements three ways, using the length, index, and substr functions.
8. Variable name fullname (length $30) has a respondents first, middle, and last name. Create var shortname (length $20), which has only the first and last name, separated by a single blank.
9. Count the number of times the string ? occurs in variable line. Choose any method that works reliably. Regardless of method, assume that a line wont consist entirely of ?s.
10. A SAS dataset has the following values for its 35 numeric variables:
99 Do not know
98 Refused to answer
97 Skipped question
Write the data step statement to convert these values to the standard sas missing value (.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!