程序代写代做代考 Quiz

Quiz

MET MA 603:
SAS Programming and Applications

Exam 1 Part II

1
1

1

No collaboration, notes, or other outside resources are allowed, except for a hand-written 3 by 5 inch index card.
Save solutions to all problems in a single SAS file and upload it to Blackboard. Grading will be based on the submitted code. Do not upload any datasets or other files.
Include your name in the name of the SAS file.
Multiple attempts are allowed as long as they are submitted before the deadline. The most recent attempt submitted before the deadline will be the one that is graded.
Points will be deducted from late submissions.
Exam Rules

2
2

2

An actuary is doing a reserve analysis using the data contained in the SAS dataset LDFs.sas7bdat.
The actuary wants to calculate a statistic for each Maturity called “Mean x-hi/lo”, which is based on the mean excluding the highest and lowest values.
For example, the Maturity of 120 has the factors 0.7620, 1.0292, 0.9251, 0.9292, 1.1735, 1.0220, and 1.0064. The highest and lowest value, 1.1735 and 0.7620, are eliminated, and the Mean x-hi/lo is calculated as:
(1.0292 + 0.9251 + 0.9292 + 1.0220 + 1.0064) / 5 = 0.9824.
Use SAS to calculate the Mean x-hi/lo statistic for each Maturity.
Question 5

3
3

3

Below is the definition of the mathematical constant e.

e can be estimated by calculating the first m terms of the sequence. The higher the value of m, the closer the estimate will be to the true value of e.
In SAS, the function exp(x) raises e to the power x, thus exp(1) = e.
Use a Do Loop to determine the value of m that will produce an estimate of e that is within 0.00001% of the true value.
Note: The function abs(x) returns the absolute value of x.
Note: The function fact(x) calculates x!

Question 6

4
4

4

Use Proc Import to create a SAS dataset based on the external file exit_poll.csv. The data contains a survey asking which candidate (Jones or Grant) each person voted for.
Use Proc Freq to identify these issues in the data (do not consider FirstName and LastName in the analysis):
An observation has one or more missing values (the observation should be removed).
An observation has illogical or contradictory data (the observation should be removed).
An observation has a word with a misspelling or inconsistent case (the word should be corrected).
Every observation has the same value for a variable (the variable should be removed).
Use a Data Step to clean the data: use IF-THEN statements and dataset options to make any necessary corrections to observations and variables.
Question 7

5
5

5

Use the Data Step to create a SAS dataset based on the external file life_insurance.txt. All variables except for “Cause” should be of the numeric datatype.
Format the resulting SAS dataset to look similar to the external file.
Question 8

6
6

6

The SAS dataset world_cup.sas7bdat was not created correctly. Use functions to create five separate variables.
The corrected dataset should look similar to the one below:
Question 9

7
7

7

Appendix

Point Distribution
Question Points
5 16
6 16
7 16
8 16
9 16
Part II Total 80

9
9

9

Formats

Informats

Character Functions

Numeric Functions

Numeric (Date-related) Functions

FormatDefinitionExample
$UPCASEw.Converts character data to uppercaseHELLO
10OCT17
MMDDYYw.Writes SAS date values in form mm/dd/yy or mm/dd/yyyy10OCT2017
TIMEw.Writes SAS times values in form hh:mm:ss.ss11:25:45.03
COMMAw.dWrites numbers with commas100,000
DOLLARw.dWrites numbers with a leading $ and commas$25.10
Writes SAS date values in form ddmmmyy or ddmmmyyyy where
mmm represents the first three letters of the month name
Datew.
12.02%
(25%)
Writes numeric data as percentages. Negative numbers indicated
with parentheses
Writes numeric data as percentages. Negative numbers indicated
with the minus sign
PERCENTNw.d
PERCENTw.d

InformatDefinition
$CHARw.Reads character data – does not trim leading or trailing blanks
$w.Reads character data – trims leading blanks
COMMAw.dRemoves embedded commas and $, converts left parentheses to minus sign
PERCENTw.dConverts percentages to numbers
Reads dates in form mmddyy or mmddyyyy where a special character such as
/ or – separates the month, day and year
MMDDYYw.
DDMMYYw.
Reads dates in form ddmmyy or ddmmyyyy where a special character such as
/ or – separates the day, month and year
Reads dates in form ddmmmyy or ddmmmyyyy where mmm represents the
first three letters of the month name
Datew.

FunctionInputsDefinition
ANYALNUM(arg)Returns position of first occurance of any alphabetic character or numeral
ANYALPHA(arg)Returns position of first occurance of any alphabetic character
ANYDIGIT(arg)Returns position of first occurance of any numeral
ANYSPACE(arg)Returns position of first occurrence of a white space character
CAT(arg1, arg2, etc.)Concatenates (combines) two or more character strings together leaving any blanks
COMPRESS(arg)Removes spaces from character data
LENGTH(arg)Returns the length of an argument (missing values have a length of 1)
FIND(arg1, arg2)Returns position of arg2 within the arg1
PROPCASE(arg)Converts first character in word to uppercase and remaining characters to lowercase
SUBSTR(arg,position,n)Extracts a substring from an argument starting at position for n characters
TRIM(arg)Removes trailing blanks from character expression
UPCASE(arg)Converts all letters in argument to uppercase

FunctionInputsDefinition
INT(arg)Returns the integer portion of the argument
LOG(arg)Returns the natural logarithm
LOG10(arg)Returns the logarithm to the base 10
MAX(arg1, arg2, etc.)Returns the largest non-missing value
MEAN(arg1, arg2, etc.)Returns the arithmetic mean of non-missing values
MIN(arg1, arg2, etc.)Returns the smallest non-missing value
SUM(arg1, arg2, etc.)Returns the sum of non-missing values

FunctionInputsDefinition
DAY(date)Returns the day of the month from a SAS date value
MDY(month,day,year)Returns a SAS date value from month, day and year values
MONTH(date)Returns the month (1-12) from a SAS date value
TODAY()Returns the current date as a SAS date value
YEAR(date)Returns the year from a SAS date value

/docProps/thumbnail.jpeg