Tag: programming languages

Questions Related to programming languages

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.

data work.company; set work.dept1(keep=jobcode) work.dept2(rename=(jcode=jobcode)); run; which one of the following is the result?

  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

The SAS dataset BANKS is listed below: BANKS name rate Capital 0.0718 Direct 0.0721 Virtual 0.0567 The following SAS program is submitted: data newbank; do year =1 to 3; set banks; capital + 5000; end; run; Which one of the following represents how many observations and variables will exist in the SAS dataset NEWBANK?

  1. 0 observations and 0 variables

  2. 1 observation and 4 variables

  3. 3 observatiosn and 3 variables

  4. 9 observations and 2 variables


Correct Option: B

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
  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