4. PROC Sort step will run successfully, PROC PRINT step generates the error.
Correct Answer : Get Lastest Questions and Answer : Explanation: As you can see whenever you need to sort the data you have to provide on which variable you want to sort. As given in the question sort step does not have any BY statement, which causes SORT step to get failed. However, dataset exist hence print step will be successful and produce the result. See below the correct syntax. proc sort data=hadoopexam.courses; by price; run; proc print data=hadoopexam.courses; run;
Question : You will be running below program proc sort data=hetrain.helr1 out=work.helr2; by FEE ID ; run;
proc print data=work.helr2 noobs; var ID DATE LOCATION FEE ; sum FEE DATE; format FEE DOLLAR9.; label DATE='Start On' LOCATION='Training Venue'; run;
Correct Answer : Get Lastest Questions and Answer : Explanation: You should check Syntax as well as each statement used in the program. Code Syntax is correct, now you can see there is a sum on two columns DATE and FEE, Hence , option 3 is out. They have used label statement hence option 4 is out. Fee has a DOLLAR format, it means some would also have the same format, so option 2 is out. And option A is correct as per given program.
Question : You have to write a program such that following conditions are met 1. Course fee is less than or equal to $4000 2. The course id is 1 or course name is ٓpark
Correct Answer : Get Lastest Questions and Answer : Explanation: As given requirement you can build your own expression and compare it with the given option. Fee<=4000 or you can write Fee le 4000 as well. Now the important thing is in 2nd requirement they want multiple conditions to be satisfied. Hence, they should be written in parenthesis to be correctly evaluated. Which you can write as below (id =1 or name = ٓpark) Now both the conditions should be satisfied. Hence, we need to use AND operator in between both the conditions. Fee<=4000 AND (id =1 or name = ٓpark) Equivalent option for this is Option 3 . Hence, option 3 is correct.
Ans : 1 Exp : A SAS date constant must take the form of one- or two-digit day, three-digit month, and two- or four-digit year, enclosed in quotation marks and followed by a d ('ddmmmyy(yy)'d).
Ans : 2 Exp : The requested output is in day-month-year order and is 10 bytes long, so DDMMYY10. is the correct format. Although WEEKDATE10. is a valid SAS format, it does not display the SAS date value as shown in the question above. DDMMYYYY10. is not a valid SAS date format, and the DATEw. format cannot accept a length of 10.
Detailed answer: Date refers to this format inside Jan [date format date format only 7,9,11] 30May00 DATE7. 30May2000 DATE9. 30-May-2000 DATE11.
format datein weekdate3.; Mon format datein weekdate6.; Monday format datein weekdate17.; Monday, Apr 5, 99 format datein weekdate21.; Monday, April 5, 1999
Question : Which one of the following displays the contents of an external file from within a SAS session? 1. the LIST procedure 2. the PRINT procedure 3. Access Mostly Uused Products by 50000+ Subscribers 4. the VIEWTABLE procedure Ans : 3 Exp : The PRINT procedure and VIEWTABLE window display the values in SAS data sets. The FSLIST procedure displays the values in external files. There is no LIST procedure in SAS.
Question : The SAS data set Sashelp.Prdsale contains the variables Region and Salary with observations per Region. Sashelp.Prdsale is sorted primarily by Region and with Region by Salary in descending order. The following program is submitted: data one; set sashelp.prdsale; retain temp; by region descending salary; if first.region then do; temp=salary; output; end; if last.region then do; range=salary-temp; output; end; run; For each region, what is the number of observations(s) written to the output data set?
Ans : 3 Exp : The expression first.region is true once for each region group. The expression last.region is true once for each region group. Therefore, each OUTPUT statement executes once for a total of 2 observations in the output data set.
Question : The following program is submitted:
proc contents data=sasuser.houses; run;
The exhibit below contains partial output produced by the CONTENTS procedure
Which of the following describes the Sasuser.Hourses data set? 1. The data set is sorted but not indexed. 2. The data set is both sorted and indexed. 3. Access Mostly Uused Products by 50000+ Subscribers 4. The data set is neither sorted nor indexed.
1. The data set Work.Test is sorted in ascending order by both Fname and Salary values. 2. The data set Work.Test is sorted in descending order by both Fname and Salary values. 3. Access Mostly Uused Products by 50000+ Subscribers 4. The data set Work.Test is sorted in ascending order by Fname and descending order by Salary values.
Correct Ans : 4 Exp : The DESCENDING keyword is placed before the variable name it modifies in the BY statement, so the correct description is in descending order by Salary value within ascending Fname values.
Question
The following SAS program is submitted: data names; title='EDU'; if title='EDU' then Division='Education'; else if title='HR' then Division='Human Resources'; else Division='Unknown'; run; Which one of the following represents the value of the variable Division in the output data set?
Ans : 2 Exp : The length of the variable Division is set to 9 when the DATA step compiles. Since the value of the variable Title is EDU, the first IF condition is true; therefore, the value of the variable Division is Education.
Question Which one of the following SAS programs creates a variable named City with a value of Chicago? 1. data work.airports; AirportCode='ord'; if AirportCode='ORD' City='Chicago'; run;
2. data work.airports; AirportCode='ORD'; if AirportCode='ORD' City='Chicago'; run;
4. data work.airports; AirportCode='ORD'; if AirportCode='ORD'; then City='Chicago'; run;
Ans : 3 Exp : The correct syntax for an IF-THEN statement is: IF expression THEN statement; In this example, the variable City is assigned a value of Chicago only if the expression AirportCode='ORD' is true.
Question : The following SAS program is submitted: data work.building; code='DAL523'; code='SANFRAN604'; code='HOUS731'; run; Which one of the following is the length of the code variable?
1. 6 2. 7 3. Access Mostly Uused Products by 50000+ Subscribers 4. 20 Ans : 1 Exp : The DATA step first goes through a compilation phase, then an execution phase. The length of a variable is set during the compilation phase and is based on the first time the variable is encountered. In this case, the variable code is set to the length of the text string DAL523 which is 6 characters long. The next assignment statements are ignored during compilation. The LENGTH statement is also ignored since the length has already been established, but a note will be written to the log.
Question Which of the following statements creates a numeric variable named IDnumber with a value of 4198? 1. IDnumber=4198; 2. IDnumber='4198'; 3. Access Mostly Uused Products by 50000+ Subscribers 4. length IDnumber $ 8; Ans :1 Exp : The first reference to the SAS variable in the DATA step sets the name, type, and length of the variable in the program data vector (PDV) and in the output SAS data set. The assignment statement IDnumber=4198; is the first reference and creates a numeric variable named IDnumber with a default storage length of 8 bytes.
Question The following SAS program is submitted:
data fltaten; input jobcode $ salary name $; cards; FLAT1 70000 Bob FLAT2 60000 Joe FLAT3 30000 Ann ; run; data desc; set fltaten; if salary>60000 then description='Over 60'; else description='Under 60'; run;
What is value of the variable named description when the value for salary is 30000? 1. Under 6 2. Under 60 3. Access Mostly Uused Products by 50000+ Subscribers 4. " (missing character value) Ans :1 Exp : The variable description is being created by the IF-THEN/ELSE statement during compilation. The first occurrence of the variable description is on the IF statement, and since it is assigned the value Over 60, the length of the variable is 7. Therefore, for the salary value of 30000, description has the value of Under 6 (the 0 is truncated.)
if salary>60000 then description='Over 60';
First appeared when the seven characters, so the length of the description is 7, so after becoming the eight-byte characters, the last one still can not tolerate
Question raw data file is listed below.
1---+----10---+----20---+--- 23 15 The following program is submitted:
data all_sales; infile 'file-specification'; input receipts; (insert statement(s) here) run; Which statement(s) complete(s) the program and produce(s) a running total of the Receipts variable?
1. total+receipts; 2. total 0; sum total; 3. Access Mostly Uused Products by 50000+ Subscribers 4. total=sum(total,receipts); Ans :1 Exp : The SUM function and the assignment statement do not retain values across iterations of the DATA step. The sum statement total+receipts; initializes total to 0, ignores missing values of receipt, retains the value of total from one iteration to the next, and adds the value of receipts to total.
The following SAS program is submitted and references the raw data file above:
data money; infile 'file-specification'; input year quantity; total=total+quantity; run;
What is the value of total when the data step finishes executing
1. 0 2. 1 3. Access Mostly Uused Products by 50000+ Subscribers 4. . (missing numeric value) Ans :4 Exp : The variable Total is assigned a missing value during the compilation phase of the DATA step. When the first record is read in, SAS processes: total=.+2; which results in a missing value. Therefore the variable Total remains missing for all observations.
total=total+quantity;
Because the right-hand side of the total did not define the very beginning, so here is total =. +2 After the state has also been missing
Question The following program is submitted:
data test; average=mean(6,4,.,2);run;
What is the value of average?
1. 0 2. 3 3. Access Mostly Uused Products by 50000+ Subscribers 4. . (missing numeric value) Ans :3 Exp :The MEAN function adds all of the non-missing values and divides by the number of non-missing values. In this case, 6 + 4 + 2 divided by 3 is 4. You can learn about the MEAN function in Transforming Data with SAS Functions.
All non-missing divided by the sum of the number of non-missing (equivalent to completely ignore missing)
Question The following SAS program is submitted:
data work.AreaCodes; Phonenumber=3125551212; Code='('!!substr(Phonenumber,1,3)!!')';run;
Which one of the following is the value of the variable Code in the output data set?
1. ( 3) 2. (312) 3. Access Mostly Uused Products by 50000+ Subscribers 4. 312 Ans :1 Exp : An automatic data conversion is performed whenever a numeric variable is used where SAS expects a character value. The numeric variable is written with the BEST12. format and the resulting character value is right-aligned when the conversion occurs. In this example, the value of Phonenumber is converted to character and right-aligned before the SUBSTR function is performed. Since there are only 10 digits in the value of Phonenumber, the right-aligned value begins with two blanks. Therefore the SUBSTR function picks up two blanks and a 3, and uses the BEST12. format to assign that value to Code. Then, the parentheses are concatenated before and after the two blanks and a 3.
In short, the numbers are right sort of - Specifically, SAS writes the numeric value with the BEST12. format, and the resulting character value is right-aligned. This conversion occurs before the value is assigned or used with any operator or function. Automatic numeric-to-character conversion can cause unexpected results. For example, suppose the original numeric value has fewer than 12 digits. The resulting character value will have leading blanks, which might cause problems when you perform an operation or function. - format refers to the instructions that SAS uses when printing variable values. If no format is specified, the default format is BEST12. for a numeric variable, and $w. for a character variable. You can assign SAS formats to a variable in the FORMAT or ATTRIB statement. You can use the FORMAT procedure to create your own format for a variable.
Question The following SAS program is submitted:
data work.inventory; products=7; do until (products gt 6); products+1; end; run;
Which one of the following is the value of the variable products in the output data set?
1. 5 2. 6 3. Access Mostly Uused Products by 50000+ Subscribers 4. 8 Ans :4 Exp : A DO UNTIL loop always executes at least once because the condition is not evaluated until the bottom of the loop. In the SAS program above, the value of Products is incremented from 7 to 8 on the first iteration of the DO UNTIL loop, before the condition is checked. Therefore the value of Products is 8.
Question : The following program is submitted: data work.test; set work.staff (keep=salary1 salary2 salary3); (insert ARRAY statement here) run; Which ARRAY statement completes the program and creates new variables?