0

programming languages Online Quiz - 121

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

PROC SORT data = lib.temp out = temp2; By subjid; Run; In which library temp2 is made?

  1. work

  2. sasuser

  3. lib

  4. syntax error


Correct Option: A

AI Explanation

To answer this question, we need to understand the PROC SORT statement in SAS and how it affects the output dataset.

The PROC SORT statement is used to sort a dataset in SAS. In the given code, the SORT procedure is used to sort the dataset named "data" from the library "lib.temp". The "By subjid" statement specifies that the dataset should be sorted by the variable "subjid".

The "out" option in the PROC SORT statement specifies the name of the output dataset. In this case, the output dataset is named "temp2".

Based on the given code, the output dataset "temp2" is created in the WORK library. The WORK library is a temporary library in SAS that is used to store temporary datasets created during a SAS session.

Therefore, the correct answer is:

Option A) work - This option is correct because the output dataset "temp2" is created in the WORK library.

options obs = 500; Data TEMP; Set test(firstobs = 75); Run; What will be the number of observations in temp dataset?

  1. 425

  2. 424

  3. 500

  4. 426


Correct Option: D

AI Explanation

To determine the number of observations in the temp dataset after executing the given SAS code, we need to understand the functionality of the SET statement and the effect of the FIRSTOBS option.

In the given code, the SET statement is used to read observations from the test dataset and store them in the temp dataset. The FIRSTOBS option is used to specify the starting observation number to read from the test dataset.

Since FIRSTOBS = 75 is specified in the SET statement, SAS will start reading observations from the test dataset starting from observation number 75.

Therefore, the number of observations in the temp dataset will be the total number of observations in the test dataset minus 74 (since we start reading from observation 75).

Given that the number of observations in the test dataset is 500, the number of observations in the temp dataset will be 500 - 74 = 426.

Therefore, the correct answer is D) 426.

PROC SORT data = temp out=new; BY JOBCODE Descending SALARY; RUN; Temp DATASET What will be the output??

  1. "temp" dataset sorted by jobcode in desending order and salary in ascending order

  2. "temp" dataset sorted by jobcode in ascending order and salary in descending order

  3. "new" dataset sorted by jobcode in ascending order and salary in descending order

  4. "new" dataset sorted by jobcode in descending order and salary in ascending order


Correct Option: C

data temp; test = ‘X’; select(test); when(‘Y’) Name = ‘Ank’; when(‘X’) Name = ‘Ankur’; when(‘Z’) Name = ‘ ’; end; run; What is the output?

  1. Ank

  2. Ankur

  3. Missing

  4. 'Ankur'


Correct Option: A

data null; put ‘test’; run; Where will the ouput(test) be written?

  1. Syntax error

  2. Log

  3. In Last file opened

  4. In dataset null


Correct Option: B

What is true about ERROR variable?

  1. d.) Will have values “TRUE” or “FALSE”

  2. c.) Will have values “YES” or “NO”

  3. b.) This variable appears in output dataset

  4. a.) Can be used in assignments/calculation in datastep.


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Will have values "TRUE" or "FALSE" - This option is incorrect. The variable "ERROR" does not have values of "TRUE" or "FALSE". It is a system variable that is automatically created in the DATA step only when an error occurs during the execution of a SAS program.

Option B) Will have values "YES" or "NO" - This option is incorrect. The variable "ERROR" does not have values of "YES" or "NO".

Option C) This variable appears in the output dataset - This option is incorrect. The variable "ERROR" does not appear in the output dataset. It is a temporary system variable that is used internally by SAS to manage errors during program execution.

Option D) Can be used in assignments/calculation in the data step - This option is correct. Although "ERROR" is a system variable, it can be used in assignments and calculations in the DATA step. It allows you to check for errors during program execution and perform specific actions based on the presence or absence of errors.

The correct answer is D) Can be used in assignments/calculation in the data step. This option is correct because "ERROR" is a system variable that can be used in assignments and calculations in the DATA step.

1----5----10--- (data in file ‘asa’) 03132000 data temp; infile ‘asa’; input date : MMDDYY10.; run; What will be stored in date?

  1. 02 January

  2. 02FEB2000

  3. 01022000

  4. 14682(number of days from 1st jan 1960)


Correct Option: D

data test; n=1; do while(n lt 6); n+1; end; run; What will be the value of n at the end of datastep?

  1. 7

  2. 6

  3. 5

  4. 8


Correct Option: B

data test; dat = '13MAR2000'd; format dat WEEKDATE.; run; What will be the value of dat in output dataset?

  1. 14682 (nmber of days from 1st jan 1960)

  2. 13MAR2000

  3. Monday, March 13, 2000

  4. Mon, March 13, 2000


Correct Option: C

data temp; set x; run; “missing code” data test; set y; run; What will be the missing code to reset the page number ?

  1. OPTIONS PAGENO = 1;

  2. OPTIONS RESET PAGENO = 1;

  3. OPTIONS RESET PAGENUMBER = 1;

  4. OPTIONS PAGENUMBER = 1;


Correct Option: A

DATA TEMP; Infile ‘filename’; Input ID $5 @; If ID = ‘RAMES’ then input Y $6 Z $10 @; else ID = ‘VIJAY’ then input R $2 @; Input age 5.; RUN; How many lines are read from input file during one execution of dataset?

  1. 2

  2. 1

  3. 3

  4. 4


Correct Option: B

AI Explanation

To determine the number of lines read from the input file during one execution of the dataset, we need to analyze the code.

The code snippet provided is using the SAS programming language. Let's break down the code step by step:

  1. DATA TEMP;: This line initializes a SAS dataset named "TEMP".

  2. Infile 'filename';: This line specifies the input file to be read. However, the file name is not provided in the code snippet.

  3. Input ID $5 @;: This line reads the first 5 characters from each line of the input file into the variable "ID".

  4. If ID = 'RAMES' then input Y $6 Z $10 @;: This line checks if the value of "ID" is equal to 'RAMES'. If it is, then it reads the next 6 characters into the variable "Y" and the following 10 characters into the variable "Z".

  5. else ID = 'VIJAY' then input R $2 @;: This line is not valid SAS syntax. It seems to be a mistake in the code.

  6. Input age 5.;: This line reads the next 5 characters from each line of the input file into the variable "age".

  7. RUN;: This line indicates the end of the data step.

Based on the code provided, we can see that only one "input" statement is valid, which is Input ID $5 @;. Therefore, only one line is read from the input file during one execution of the dataset.

So, the correct answer is:

B) 1

How to write comma separated file?

  1. a.) FILE ‘filename’ dsd = ‘,’;

  2. b.) FILE ‘filename’ dlm = ‘ ’ dsd = ‘,’;

  3. c.) FILE ‘filename’ dlm = ‘,’;

  4. d.) FILE ‘filename’ csv = ‘,’;


Correct Option: C

1----5----10----15----(file ‘abc’) RAM,,20 RAJU,SHARMA,24 DATA temp; Infile ‘abc’ dsd; Input FNAME $ LNAME $ AGE; RUN; What will be the value of LNAME for 1st observation?

  1. ‘,’

  2. blank character value

  3. ‘SHARMA’

  4. syntax error


Correct Option: B

libname temp ‘abc.sds.as’; data temp.X1; set sasuser.X2; run; Which is the correct statement??

  1. In datastep input is read from temporary location and output is written to temporary location.

  2. .) In datastep input is read from permanent location and output is written to temporary location.

  3. In datastep input is read from temporary location and output is written to permanent location.

  4. In datastep input is read from permanent location and output is written to permanent location.


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) In datastep input is read from temporary location and output is written to temporary location. This option is incorrect because the LIBNAME statement libname temp ‘abc.sds.as’; specifies the library temp as a permanent location, not a temporary location.

Option B) In datastep input is read from permanent location and output is written to temporary location. This option is incorrect because the LIBNAME statement libname temp ‘abc.sds.as’; specifies the library temp as a permanent location, not a temporary location. Additionally, the output dataset temp.X1 is stored in the library temp, which is a permanent location.

Option C) In datastep input is read from temporary location and output is written to permanent location. This option is incorrect because the LIBNAME statement libname temp ‘abc.sds.as’; specifies the library temp as a permanent location, not a temporary location. Additionally, the output dataset temp.X1 is stored in the library temp, which is a permanent location.

Option D) In datastep input is read from permanent location and output is written to permanent location. This option is correct because the LIBNAME statement libname temp ‘abc.sds.as’; specifies the library temp as a permanent location. The input dataset sasuser.X2 is read from a permanent location (the sasuser library), and the output dataset temp.X1 is written to a permanent location (the temp library).

The correct answer is D) In datastep input is read from permanent location and output is written to permanent location.

What is the output of DATE9. format?

  1. 11/31/2000

  2. 31/11/2000

  3. 31NOV2000

  4. 01NOVEMBER2000


Correct Option: C

data a; do X=1 to 3 ; input ID NAME $ AGE; end; datalines; 01 vivek 22 02 vital 25 03 rajes 20 ; What will be the number of observations and variables in output dataset??

  1. 3 and 3

  2. 1 and 3

  3. 1 and 4

  4. 3 and 1


Correct Option: C

AI Explanation

To determine the number of observations and variables in the output dataset, let's go through the given code step by step.

The code snippet data a; initializes a dataset named "a".

The do X=1 to 3; statement starts a loop that iterates from 1 to 3.

Within the loop, the input ID NAME $ AGE; statement reads three variables from the input data: ID (numeric), NAME (character), and AGE (numeric).

The end; statement marks the end of the loop.

The datalines; statement indicates that the input data is provided in the following lines.

The input data is given as:

01 vivek 22 02 vital 25 03 rajes 20

From the input data, we can see that there are 3 observations and 3 variables (ID, NAME, AGE).

Therefore, the correct answer is:

C) 1 and 4

What informat should be used to read the date variable in the flat file having the values like 02NOV2003?

  1. DATE9.

  2. MMDDYY8.

  3. MMDDYY10.

  4. none


Correct Option: A

Flat file structure is as below 1----5----10 $1,120 The following code is submitted. data temp; infile ‘file specification’; input salary 5; run; What would be the value of SALARY in the dataset TEMP

  1. blank value

  2. $1,120

  3. 2

  4. .


Correct Option: C

AI Explanation

To answer this question, let's understand the code and its impact on the dataset.

The given code is reading data from a file specified in the "infile" statement and creating a dataset named "temp". The "input" statement is used to define the variables and their lengths to be read from the file. In this case, "salary" is defined with a length of 5.

Based on the given flat file structure, the value "1,120" is located at positions 1 to 5. Since "salary" is defined with a length of 5, it will read the value "1,120" from the file.

Therefore, the value of SALARY in the dataset TEMP would be 2.

So, the correct answer is Option C: 2.

Format name or Informat name should end with a dot eg:DATE9.

  1. True

  2. False


Correct Option: A

data temp; length y $5; x=4; if x=4 then y='four'; else if x=7 then y='seven'; x=7; run; What would be the value of X and Y in the dataset temp?

  1. X=4 and Y= ‘seven’

  2. X=7 and Y=’seven’

  3. X=7 and Y=’four’

  4. X=4 and Y=’four’


Correct Option: C
- Hide questions