程序代写 1. Fundamental Concepts – cscodehelp代写

1. Fundamental Concepts
Answer TRUE or FALSE to the following sentences.
0. ____________ The two types of steps that can make up a SAS program are DATA and PROC.
0. ____________ A DATA step must use a SAS data set as input.
0. ____________ A statement always ends in a colon.
0. ____________ A global statement stays in effect for only the subsequent step.
0. ____________ The LIBNAME statement assigns a logical name to a SAS data library.
0. ____________ Data sets are referenced using a four-level name.
0. ____________ Data sets located in the Sasuser data library are considered temporary.
0. ____________ A variable name and the name of a data set can be up to 32 characters long.
0. ____________ By default, a variable name can contain special characters such as a dash ().
0. ____________ A numeric variable is stored as 32 bytes by default.
0. ____________ A numeric variable can be stored with digits, decimal point, comma, minus sign,
and E for scientific notation.
0. ____________ A character variable is stored as 1 to 32,767 bytes.
0. ____________ A SAS date value represents the number of days between January 1, 1960, and
a specific date.
0. ____________ A missing numeric value is represented with a zero.
0. ____________ A missing character value is represented with a blank.
0. ____________ The DESCRIPTOR procedure views the descriptor portion of a SAS data set.
0. ____________ A statement that starts with an asterisk is a SAS comment.
0. ____________ The SAS log contains messages starting with the words NOTE, SUGGESTION,
and ERROR.
1. DATA Step Merge
Below is the input data set work.employees:

Below is the input data set work.salaries:

Below is the output data set work.empsal:

Add the appropriate statement to the following program to create the output data set based on the input data sets:
data empsal;

by idnum;
if emp=1 and sal=1;
run;
1. Column, Formatted, and List Input
Below is the raw data file kids7.dat:
—-|—-10—|—-20—|—-30—|—-41—|
15$1,322!Tim! McMurray 12$532! Jones 14$1,000!Jim!John! is the desired output data set, work.kids7:

Complete the following program based on the raw data file kids7.dat and the desired output data set work.kids7. Use column input for first, last, and age. Use list input for savings, sibling1, sibling2, and sibling3.
data work.kids7;

infile ‘kids7.dat’ ;

input

;

run;
1. IF-THEN DO / ELSE DO Statements
Answer the questions based on the following program:
data newprice;
infile ‘raw-data-file’;
input mfg $ type $ price;
length saletype $ 18;
if mfg=’Crew’ then do;
pct=0.75;
saleprice = price * pct;
saletype = ‘25% off’;
end;
else if mfg=’Hi-fly’ then do;
pct=0.70;
saleprice = price * pct;
saletype = ‘30% off’;
end;
else do;
pct=0.90;
saleprice = price * pct;
saletype = ‘10% Storewide Sale’;
end;
format price saleprice dollar8.2;
run;
3. How many DO blocks are in the program?
3. How many variables will be assigned values if an expression is true?
3. How many of those variables are numeric?
3. What is the byte size of pct?
3. What would be the byte size of saletype if the LENGTH statement were not part of the program?
3. How many ELSE statements are in the program?
3. Why is the word ELSE used?
3. Why are the DO blocks needed?
3. What stops each DO block?
3. Will the value of pct ever be missing in the data set?

1. Character Functions
Place the appropriate letter before each function.
_____ CATS _____ PROPCASE
_____ CATX _____ RIGHT
_____ COMPBL _____ SCAN
_____ COMPRESS _____ STRIP
_____ FIND _____ SUBSTR
_____ LEFT _____ TRANWRD
_____ LENGTH _____ TRIM
_____ LOWCASE _____ UPCASE
a. Concatenates character strings and removes leading and trailing blanks
b. Selects a given word from a character expression
c. Replaces or removes all occurrences of a word in a character string
d. Converts all letters in an argument to lowercase
e. Right-aligns a character expression
f. Removes multiple blanks from a character string
g. Searches a character expression for a string of characters with the capability of ignoring case and trimming trailing blanks
h. Extracts a substring from an argument
i. Converts all letters in an argument to uppercase
j. Returns a character string with specified characters removed from the original string
k. Removes trailing blanks from character expressions
l. Returns an integer that represents the position of the rightmost non-blank character in a string
m. Left-aligns a character expression
n. Concatenates character strings, removes leading and trailing blanks, and inserts separators
o. Converts all words in an argument to proper case
p. Removes leading and trailing blanks from character expressions

1. Output Delivery System
Fill in the blanks in the following program to complete the program and answer the questions:
ods listing;

ods html _______________ = ‘steel.html’;

ods _______________ file = ‘steel.xml’;

proc sort data=sashelp.steel out=steel;
by date;
run;

proc print data=steel;
run;

proc freq data=steel;
tables date;
run;

ods _all_ _______________;

ods listing;
5. How many destinations are open in the program?
5. How many reports are sent to the open destinations?

1. Fitting a Simple Linear Regression Model

Use the BodyFat2 data set (the one used in the previous exercise) for this exercise.
a. Perform a simple linear regression model with PctBodyFat2 as the response variable and Weight as the predictor.
b. Produce predicted values for PctBodyFat2 when Weight is 125, 150, 175, 200, and 225 (Data are stored in the BodyFat To Score dataset in the SAS USER library.)
c. What are the predicted values?

1. Psychologists at a college want to know if students are sleeping more or less than the recommended average of 8 hours a day.
Which of the following code choices correctly tests the null hypothesis?

 a.  
proc univariate data=statdata.sleep mu0<>8;
var hours;
run;

 b.  
proc univariate data=statdata.sleep;
var hours / mu0=8;
run;

 c.  
proc univariate data=statdata.sleep;
var hours / mu0<>8;
run;

 d.  
proc univariate data=statdata.sleep mu0=8;
var hours;
run;

Leave a Reply

Your email address will not be published. Required fields are marked *