SAS Midterm
Which of the following SAS statements will execute without syntax errors (dateone is a variable in data set a)? (a) data b; set a;where dateone between "01FEB1960"d and "01MAR1960"d; run; (b) data b; set a; if dateone between "01FEB1960"d and "01MAR1960"d; run; (c) data b; set a; where dateone between "01/02/1960"d and "01/03/1960"d; run; (d) (a) and (b) (e) (a) and (c) (f) (a), (b), and (c) (g) None
(a) data b; set a;where dateone between "01FEB1960"d and "01MAR1960"d; run;
Which of the following format value name is valid? 1. $Money 2. Is3 3. ILove$ 4. 2Go
1. $Money
Which of the following programs contains a syntax error? 1. proc sort data=sasuser.mysales; by region;run; 2. dat sasuser.mysales; set mydata.sales99;run; 3. proc print data=sasuser.mysales label; label region='Sales Region';run; 4. none of the above
2. dat sasuser.mysales; set mydata.sales99;run;
What values will be assigned to variable X and Y? data a; x1 = 2; x2 = 5; x3 = 10; X= x1+x3/x2; Y = (x1+x3)/x2; run; 1) X = 2.4 and Y = 2.4 2) X = 4 and Y = 4 3) X = 4 and Y = 2.4 4) X = 2.4 and Y = 4
3) X = 4 and Y = 2.4
Which of the following variable names is valid? 1. 2me 2. ILove$ 3. _NoBody_ 4. Principle-Dividend
3. _NoBody_
How many different types of data supported by SAS? 1) 4 2) 6 3) 8 4) 2
4) 2
When a date value is read from a worksheet, it is converted automatically to a SAS date. Which SAS format is used to display the value? 1) MMDDYY8. 2) MMDDYY10. 3) DATE7. 4) DATE9.
4) DATE9.
What does the program shown here create? ibname sales excel 'c:\mydata\sta5104.xls';data sales.qtr1_2011; set sasdata.qtr1_2011;run;data sales.qtr2_2011; set sasdata.qtr2_2011;run; 1) a data set named sales.qtr1_2011 and a data set named sales.qtr2_2011 2) an Excel workbook named sales.qtr1_2011 and an Excel workbook named sales.qtr2_2011 3) an Excel workbook named sales that contains two worksheets, qtr1_2011 and qtr2_2011 4) an Excel workbook named sta5104 that contains two worksheets, qtr1_2011 and qtr2_2011
4) an Excel workbook named sta5104 that contains two worksheets, qtr1_2011 and qtr2_2011
Which of the following files is a permanent SAS file? 1. mylib.myjob 2. sasmap.usa 3. sashelp.myhelpfile 4. all of above
4. all of above
The number of variables in the data set work.comp is_______. data work.comp(drop=Salary Hire_Date); set orion.sales(keep=Employee_ID First_Name Last_Name Salary Hire_Date); Bonus=500;Compensation=sum(Salary,Bonus); BonusMonth=month(Hire_Date); run;
6
If we want to cancel the SAS library orionxls, we can use the statement "libname orionxls________________;".
CLEAR
Which of the following is a SAS syntax requirement? a. Begin each statement in column one. b. Put only one statement on each line. c. Separate each step with a line space. d. End each statement with a semicolon e. Put a RUN statement after every DATA or PROC step
End each statement with a semicolon
"10101911"d represents the SAS date constant for October 10, 1911.
FALSE
"Where" statement can only be used in PROC steps and "if" statement can only be used in Data steps.
FALSE
Each SAS statement must be on the same line and SAS does not allow multiple statements on the same line
FALSE
If a SAS program produces output, then the program ran correctly and there is no need to check the SAS log.
FALSE
If a SAS program produces output, then the program ran correctly, and there is no need to check the SAS log.
FALSE
SAS allows user to define character variable with length no longer than 32 characters
FALSE
SAS allows user to define variables as short inteer, long inteer, and single precision floating point number, and double precision floating point number
FALSE
SAS does not allow numerical variables to have any missing values
FALSE
The following two SAS "where" conditions are equivalent since SAS is not case sensitive. (a) "where action in ('A', 'P', 'X');" (b) "where action in ('a', 'p', 'x');" =ANSWER T OR F=
FALSE
The following two SAS statements are equivalent. (a) "variable = SUM(argument1, argument2);" (b) "variable=augument1+augument2;"
FALSE
The minimum length of a numerical variable is 1 in SAS.
FALSE
The order of your statements in a DATA step does not matter
FALSE
The following DATA step reads a temporary SAS data set to create a permanent SAS data set. data work.mycustomers; set orion.customer; run;
False
Which of the following steps is typically used to generate reports and graphs? a. DATA b. PROC c. REPORT d. RUN
PROC step
A SAS date value is interpreted as the number of days between January 1, 1960 and that date
TRUE
A percent sign (%) replaces one character and an underscore (_) replaces any number of characters. For example, the where condition, "where Code like 'E_U%';", will pick up Code="EEEEUU" and "EUUUUUE".
TRUE
A single SAS Statement can span multiple lines
TRUE
Both "QTR" and "MDY" are SAS functions..
TRUE
Omitting a semicolon causes errors in SAS.
TRUE
SAS Statements always end with a semicolon
TRUE
SAS library "SASUSER" is a permanent SAS data library.
TRUE
SAS library "Work" is a SAS temporary data library.
TRUE
SAS uses blank to represent missing value of a character variable
TRUE
The statement "where Country in ('AU','US');" is equivalent to the statement "where Country in ('AU' 'US');", Country in ("AU" "US"), and Country in ("AU", "US").
TRUE
The statement "where salary between 70000 and 100000;" is equivalent to the statement "where 70000 <=salary <= 100000;".
TRUE
You can use the LIBNAME statement to assign a libref to a SAS data library.
TRUE
Which of the following is not true of SAS date values? a. They are numeric b. they can be positive or negative values c. they represent the number of days between the day being stored and a base date d. the base date is January 1, 1900
The base date is January 1, 1900
Which of the following is not true of SAS date values? a. They are numeric. b. They can be positive or negative values. c. They represent the number of days between the day being stored and a base date. d. The base date is January 1, 1900.
The base date is January 1, 1900
Write a "where statement selects observations that begin with a T, followed by a single character, followed by an M, and followed by any number of characters.
Where variable contain "T_M%";
Use PROC CONTENTS with the _________________ keyword to generate a list of all SAS files in a library.
_ALL_
During the compilation phase, SAS scans each statement in the DATA step, looking for syntax errors. Which of the following is not considered a syntax error? a. incorrect values and formats b. invalid options or variable names c. missing or invalid punctuation d. missing or misspelled keywords
a. incorrect values and formats
Look carefully at the DATA step shown below. Based on the INPUT statement, in what order will the variables be stored in the new data set? data perm.update; infile invent; input IDnum $ 15-19 Item $ 1-13 Instock 21-22 BackOrd 24-25; Total=instock+backord; run; a.IDnum Item InStock BackOrd Total b.Item IDnum InStock BackOrd Total c.Total IDnum Item InStock BackOrd d.Total Item IDnum InStock BackOrd
a.IDnum Item InStock BackOrd Total
What is wrong with this program? data perm.update; infile invent input Item $ 1-13 IDnum $ 15-19 Instock 21-22 BackOrd 24-25; total=instock+backord; run; a.missing semicolon on second line b.missing semicolon on third line c.incorrect order of variables d.incorrect variable type
a.missing semicolon on second line
What result would you expect from submitting this step? proc print data=work.newsalesemps run; a. an HTML report of the work.newsalesemps data set b. an error message in the log c. a listing report of the work.newsalesemps data set d. the creation of the temporary data set work.newsalesemps
an error message in the log
Which of the following statement(s) is (are) correct? a) Date1 = "01011960"d; b) Date2 = "01JAN1960"d; c) Date3 = "01jan1960"d; d) Date4 = "JAN011960"d; e) Date5 = "01/01/1960"d; f) All of the above.
b) Date2 = "01JAN1960"d; c) Date3 = "01jan1960"d;
How do you specify a SAS date constant for October 10, 2007? a. '10102007'd b. '10OCT2007'd c. '10/10/2007'x d. OCT 10, 1007
b. '10OCT2007'd
Suppose you run a program that causes three DATA step errors. What is the value of the automatic variable _ERROR_ when the observation that contains the third error is processed? a. 0 b. 1 c. 2 d. 3
b. 1
You can place the FORMAT statement in either a DATA step or a PROC step. What happens when you place it in a DATA step? a. You temporarily associate the formats with variables. b. You permanently associate the formats with variables. c. You replace the original data with the format labels. d. You make the formats available to other data sets.
b. You permanently associate the formats with variables.
The format JOBFMT was created in a FORMAT procedure. Which FORMAT statement will apply it to the variable JobTitle in the program output? a. format jobtitle jobfmt; b. format jobtitle jobfmt.; c. format jobtitle=jobfmt; d. format jobtitle='jobfmt';
b. format jobtitle jobfmt.;
Which of the following FORMAT procedures is written correctly? a. proc format lib=library value colorfmt; 1='Red' 2='Green' 3='Blue' run; b. proc format lib=library; value colorfmt 1='Red' 2='Green' 3='Blue'; run; c. proc format lib=library; value colorfmt; 1='Red' 2='Green' 3='Blue' run; d. proc format lib=library; value colorfmt 1='Red'; 2='Green'; 3='Blue'; run;
b. proc format lib=library; value colorfmt 1='Red' 2='Green' 3='Blue'; run;
Which of the following is not created during the compilation phase? a. the data set descriptor b. the first observation c. the program data vector d. the _N_ and _ERROR_ automatic variables
b. the first observation
Which WHERE statement correctly subsets the numeric values for May, June, or July and missing character names?a. where Month in (5-7) and Names=.; b. where Month in (5,6,7) and Names=' '; c. where Month in ('5','6','7') and Names='.';
b. where Month in (5,6,7) and Names=' ';
Which of the following statements can be used in a DATA step? a.CLASS statement b.IF-THEN-ELSE statements c.VAR statement d.a and b above
b.IF-THEN-ELSE statements
Which of the following IF-THEN-ELSE statements will execute without syntax errors? a. IF dest = 'DFW' THEN revenue = (boarded + transfer) * 600;END;ELSE IF dest = 'LAX' THEN revenue = (boarded + transfer) * 900;END; b. IF dest = 'DFW' THEN DO;revenue = (boarded + transfer) * 600;ELSE IF dest = 'LAX' THEN DO;revenue = (boarded + transfer) * 900; c. IF dest = 'DFW' THEN revenue = (boarded + transfer) * 600;ELSE IF dest = 'LAX' THEN revenue = (boarded + transfer) * 900;
c. IF dest = 'DFW' THEN revenue = (boarded + transfer) * 600;ELSE IF dest = 'LAX' THEN revenue = (boarded + transfer) * 900;
Which step sorts the observations in a SAS data set and overwrites the same data set? a. proc sort data=work.EmpsAU out=work.sorted;by First; run; b. proc sort data=orion.EmpsAU out=EmpsAU; by First; run; c. proc sort data=work.EmpsAU; by First; run;
c. proc sort data=work.EmpsAU; by First; run;
How many characters can be used in a label? a. 40 b. 96 c. 200 d. 256
d. 256
What are the required attributes for all variables? a. length b. data type c. variable name d. All of above
d. All of above
At the beginning of the execution phase, the value of _N_ is 1, the value of _ERROR_ is 0, and the values of the remaining variables are set to: a. 0 b. 1 c. Undefined d. Missing
d. Missing
Which keyword can be used to label missing numeric values as well as any values that are not specified in a range? a. LOW b. MISS c. MISSING d. OTHER
d. OTHER
Which of these is false? Ranges in the VALUE statement can specify... a. a single value, such as 24 or 'S'. b. a range of numeric values, such as 0-1500. c. a range of character values, such as 'A'-'M'. d. a list of numeric and character values separated by commas, such as 90,'B',180,'D',270.
d. a list of numeric and character values separated by commas, such as 90,'B',180,'D',270.
When creating a format with the VALUE statement, the new format's name cannot end with a number cannot end with a period cannot be the name of a SAS format, and... a. cannot be the name of a data set variable. b. must be at least two characters long. c. must be at least eight characters long. d. must begin with a dollar sign ($) if used with a character variable
d. must begin with a dollar sign ($) if used with a character variable
Suppose you already ran the first program, which created a one-page report. Next, you want to run the second program. What will appear at the top of the second report? 1.title1 'RADIX Company'; 2.title3 'DVD Sales'; 3.proc print data=radix.sales; title2 'Best Sales'; title; proc print data=radix.staff; where Sales>25000; run; /* Second Program */; a. no titles b. RADIX CompanyBest SalesDVD Sales c. RADIX CompanyBest Sales d. RADIX Company
no title
Suppose you submit a short, simple DATA step. If the active window displays the message DATA step running for a long time, what probably happened? a. you misspelled a keyword b. you forgot to end the DATA step with a RUN statement c. you specified an invalid data set option. d. some data values were not appropriate for the SAS statement that you specified.
you forgot to end the DATA step with a RUN statement.