0

programming languages Online Quiz - 119

Description: programming languages Online Quiz - 119
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

data work.flights; destination='cph'; select(destination); when('LPR') city='London'; when('CPH') city = 'Copenhagen'; otherwise city='Other'; end; run; which one of the following is the value of the CITY variable?

  1. Other

  2. Copenh

  3. Copenhagen

  4. Missing


Correct Option: A

data work.passengers; if origpassengers=. then origpassengers = 100; transpassengers=100; origpassengers=.; nonpaying=10; totalpassengers = origpassengers + Transpassengers; run; which one of the following is the value of the totalpassengers variable in the output data set?

  1. 100

  2. 110

  3. 200

  4. missing


Correct Option: D

AI Explanation

To determine the value of the totalpassengers variable in the output data set, let's go through each step of the SAS code provided:

  1. data work.passengers;: This line of code creates a new SAS data set named passengers in the work library.

  2. if origpassengers=. then origpassengers = 100;: This line of code checks if the origpassengers variable is missing (.). If it is missing, it assigns a value of 100 to origpassengers. However, since origpassengers is not explicitly defined in the code, it is assumed to be missing.

  3. transpassengers=100;: This line of code assigns a value of 100 to the transpassengers variable.

  4. origpassengers=.;: This line of code assigns a missing value to the origpassengers variable. This line is executed after step 2, so the value assigned in step 2 is overwritten by the missing value.

  5. nonpaying=10;: This line of code assigns a value of 10 to the nonpaying variable.

  6. totalpassengers = origpassengers + Transpassengers;: This line of code calculates the sum of the origpassengers and transpassengers variables and assigns the result to the totalpassengers variable. Since both origpassengers and transpassengers are missing, the sum will also be missing.

  7. run;: This line of code signals the end of the data step.

Therefore, the value of the totalpassengers variable in the output data set is missing (Option D).

data work.passengers; if origpassengers=. then origpassengers = 100; transpassengers = 100; origpassengers = .; nonpaying = 10; totalpassengers = sum(origpassengers ,transpassengers); run; Which one of the following is the value of the TOTALPASSENGERS variable in the output dataset?

  1. 100

  2. 110

  3. 200

  4. missing


Correct Option: B

AI Explanation

To determine the value of the TOTALPASSENGERS variable in the output dataset, let's go through the code step by step:

  1. data work.passengers; - This line creates a new dataset named "passengers" in the "work" library.

  2. if origpassengers=. then origpassengers = 100; - This line checks if the variable "origpassengers" is missing. If it is missing, it assigns a value of 100 to it.

  3. transpassengers = 100; - This line assigns a value of 100 to the variable "transpassengers".

  4. origpassengers = .; - This line assigns a missing value to the variable "origpassengers", overwriting the previous value of 100.

  5. nonpaying = 10; - This line assigns a value of 10 to the variable "nonpaying".

  6. totalpassengers = sum(origpassengers, transpassengers); - This line calculates the sum of the variables "origpassengers" and "transpassengers" and assigns the result to the variable "totalpassengers".

  7. run; - This line executes the data step and creates the output dataset.

Since the value of "origpassengers" is missing and the value of "transpassengers" is 100, the sum of these two variables will be 100. Therefore, the value of the TOTALPASSENGERS variable in the output dataset will be 100.

The correct answer is option A) 100.

  1. The variable JCODE is written to the output data set

  2. The variable JOBCODE is written to the output data set

  3. Neither variable JCODE nor JOBCODE is written to the output dataset

  4. The program fails to execute due to errors


Correct Option: B

Input data is provided: squash 1.10 apples 2.25 juice 1.69 The following SAS program is submitted using the raw data file above: data groceries; infile 'file-specification'; input item $ cost; ---------------- run; Which one of the following completes the program and produces a grand total for all COST values?

  1. grandtot = sum cost

  2. grandtot = sum(grandtot,cost)

  3. retain grandtot 0;grandtot + cost;

  4. grandtot = grandtot+ cost


Correct Option: C

data work.sales; do year=1 to 5; do month = 1 to 12; x + 1; end; end; run; which one of the following represents how many observations are written to the WORK.SALES dataset

  1. 0

  2. 1

  3. 5

  4. 60


Correct Option: B

data work.clients; calls= 6; do while (calls le 6); calls+1; end; run; which one of the following is the value of the variable CALLS in the output data set

  1. 4

  2. 5

  3. 6

  4. 7


Correct Option: D

The value 110700 is stored in a numeric variable.which one of the following SAS formats is used to display the value as $110,700.00 in a report.

  1. comma11.2

  2. comma8.2

  3. dollar11.2

  4. dollar8.2


Correct Option: C

A realtor has two customers.One customer wants to view a list of homes selling for less than $60,000.the other customer wants to view a list of homes selling for greater than $100,000.Assuming the PRICE variable is numeric,which one of the following PRINT procedure steps will select all desired observations.

  1. proc print data=sasuser.houses; where price lt 60000;where price gt 100000;run;

  2. proc print data=sasuser.houses; where price lt 60000 or price gt 100000;run;

  3. proc print data=sasuser.houses; where price lt 60000 and price gt 100000;run;

  4. proc print data=sasuser.houses; where price lt 60000 or where price gt 100000;run;


Correct Option: B

which one of the following System option displays the time on the report

  1. DATE

  2. TIME

  3. TODAY

  4. DATETIME


Correct Option: A

data work.january; set work.allmonths(keep = product month num_sold cost); if month='Jan' then output work.january; sales = cost * num_sold; keep = product sales; run; which variable does the work.january dataset contain?

  1. product and sales only

  2. product month num_sold cost

  3. product sales month num_sold cost

  4. An incomplete output dataset is created due to syntax errors


Correct Option: D

which one of the following statements is true when SAS encounters a data error in a DATA step?

  1. The DATA step stops executing at the point of the error and no SAS dataset is created

  2. A note is written to the SAS log expalining the error and the DATA step continues to execute

  3. A note appreas in the SAS log that the incorrect data record was saved to a seperate SAS file for further examiantion

  4. The DATA step stops executing at the point of the error and the resulting DATA set contains observations up to that point


Correct Option: B

AI Explanation

To answer this question, we need to understand what happens when SAS encounters a data error in a DATA step.

Option A) The DATA step stops executing at the point of the error and no SAS dataset is created - This option is incorrect. When SAS encounters a data error in a DATA step, it does not necessarily stop executing at the point of the error. Instead, it continues to execute unless specified otherwise.

Option B) A note is written to the SAS log explaining the error and the DATA step continues to execute - This option is correct. When SAS encounters a data error in a DATA step, it writes a note to the SAS log explaining the error and continues to execute the remaining part of the DATA step. This allows SAS to process as much of the data as possible, even if there are errors.

Option C) A note appears in the SAS log that the incorrect data record was saved to a separate SAS file for further examination - This option is incorrect. SAS does not automatically save the incorrect data record to a separate SAS file. However, you can manually code SAS statements to capture and save problematic records for further examination.

Option D) The DATA step stops executing at the point of the error and the resulting DATA set contains observations up to that point - This option is incorrect. As mentioned earlier, SAS does not necessarily stop executing at the point of the error. It continues to execute the remaining part of the DATA step.

Therefore, the correct answer is B. When SAS encounters a data error in a DATA step, a note is written to the SAS log explaining the error, and the DATA step continues to execute.

$1,234 The following SA sprogram is submitted data test; infile 'amount'; input @1 salary 6.; run; which one of the following is the value of the salary variable?

  1. 1234

  2. 1,234

  3. $1,234

  4. .(missing numeric value)


Correct Option: D

The contents of the raw data file NAMENUM are listed below: Joe xx The following SAS program is submitted: data test; infile 'namenum'; input name $ number; run; which one of the following is the value of the NUMBER variable?

  1. xx

  2. Joe

  3. .(missing numeric value)

  4. The value cannot be deteremined as the program fails to execute due to errors


Correct Option: C

Local variables do Not get a default value

  1. True

  2. False


Correct Option: A

Is instance variables are overriden?

  1. True

  2. False


Correct Option: B

What is the super calss of class?

  1. Nothing

  2. Class object

  3. class

  4. calss reference


Correct Option: B
- Hide questions