Uncategorized

Doing More with SAS Programming Quiz

Doing More with SAS Programming Quiz Answer. In this post you will get Quiz Answer Of Doing More with SAS Programming

 

Doing More with SAS Programming Quiz

Offered By ”SAS”

Enroll Now

Week- 1

Controlling DATA Step Processing

1.
Question 1
Which statement is false concerning the compilation phase of the DATA step?

1 point

The program data vector (PDV) is created.

Initial values are assigned to the columns.

The descriptor portion of the output table is created.

The DATA step is checked for syntax errors.

2.
Question 2
Which statement is not a compile-time-only statement?

1 point

SET

WHERE

KEEP

LENGTH

3.
Question 3
Which statement is true concerning the execution phase of the DATA step?

1 point

An implied REINITIALIZE occurs at the bottom of the DATA step.

An implied OUTPUT occurs at the top of the DATA step.

Data is processed in the program data vector (PDV).

Columns read from the input table are set to missing when SAS returns to the top of the DATA step.

4.
Question 4
Which PUTLOG statements create the following results in the SAS log?

12
Name=Alfred Height=69 Weight=112.5 Ratio=0.61 _ERROR_=0 _N_=1
Ratio=0.61
1 point

putlog _all_; putlog Ratio=;

putlog all; putlog Ratio=;

putlog all; putlog Ratio;

putlog _all_; putlog Ratio;

5.
Question 5
How many rows and columns are in the output table ShippingZones given the following information?

The input table Shipping contains 5 rows and 3 columns (Product, BoxSize, and Rate).

12345678
data ShippingZones;
set Shipping;
Zone=1;
output;
Zone=2;
Rate=(Rate*1.5);
run;

1 point

10 rows and 3 columns

10 rows and 4 columns

5 rows and 4 columns

5 rows and 3 columns

6.
Question 6
The sashelp.cars table contains 428 rows: 123 rows with Origin equal to Europe and 305 rows with Origin equal to other values.

How many rows will be in the Other table?

1234567
data Europe Other;
set sashelp.cars;
if Origin=’Europe’ then
output Europe;
output Other;
run;

1 point

428 rows

0 rows

123 rows

305 rows

7.
Question 7
Which statement is false?

1 point

The DROP statement names the columns to exclude from the output table.

The KEEP= option in the DATA statement names the columns to include in the output table.

The KEEP statement names the columns to include from the input table.

The DROP= option in the SET statement names the columns to exclude from being read into the PDV.

8.
Question 8
Which columns are in the final table work.boots?

7
data work.boots(drop=Product);
set sashelp.shoes(keep=Product Subsidiary Sales Inventory);
where Product=’Boot’;
drop Sales Inventory;
Total=sum(Sales,Inventory);
run;

1 point

Product, Subsidiary, Sales, and Inventory

Subsidiary and Total

Subsidiary

Product and Subsidiary

9.
Question 9
What is the result of running the following DATA step?

6
data work.boots;
set sashelp.shoes(keep=Product Subsidiary);
where Product=’Boot’;
NewSales=Sales*1.25;
run;

1 point

The step produces work.boots with three columns.

The step produces an error because the Sales column is not read in from the sashelp.shoes table.

The step produces work.boots with four columns.

The step produces an error due to invalid syntax for the KEEP= option.

 

 

Week- 2

Summarizing Data

1.
Question 1
Which statement contains valid syntax for the RETAIN statement?

1 point

retain Year{2018};

retain Year*2018;

retain Year=2018;

retain Year 2018;

2.
Question 2
Which statement is false concerning the sum statement?

1 point

The sum statement ignores missing values.

The sum statement initially sets the accumulator column to missing.

The sum statements adds a numeric value to an accumulator column.

The sum statement automatically retains the value of the accumulating column.

3.
Question 3
What is the value of Count at the end of the third DATA step iteration?

12345
data newnums;
set nums;
retain Count 100;
Count+Tens;
run;
1 point

60

. (missing)

130

160

4.
Question 4
What is the value of Count at the end of the third DATA step iteration?

1234
data newnums;
set nums;
Count+Tens;
run;
1 point

20

30

. (missing)

40

5.
Question 5
Which step executes successfully without an error, given the input table sashelp.class?

1 point

123456
data new;
set sashelp.class;
where Sex=’M’;
Ratio=Height/Weight;
if Ratio>0.6;
run;

123456
data new;
set sashelp.class;
where Sex=’M’;
Ratio=Height/Weight;
where Ratio>0.6;
run;

12345
data new;
set sashelp.class;
Ratio=Height/Weight;
where Sex=’M’ & Ratio>0.6;
run;

123456
data new;
set sashelp.class;
if Sex=’M’;
Ratio=Height/Weight;
where Ratio>0.6;
run;
6.
Question 6
Which statement is true given the following program?

1234
data work.student;
set sashelp.class;
by Name;
run;
1 point

The DATA step sorts the input table by the column Name.

An error is produced because the BY statement is not permitted in the DATA step.

The output table work.student contains a column named Last.Name.

The PDV contains a temporary variable named First.Name.

7.
Question 7
What are the correct values for First.Name and Last.Name if the value of Name appears only once in the input table?

1234
data work.student;
set sashelp.class;
by Name;
run;
1 point

First.Name=0 and Last.Name=0

First.Name=1 and Last.Name=1

First.Name=0 and Last.Name=1

First.Name=1 and Last.Name=0

8.
Question 8
Which DATA step statement indicates to continue processing the last row of a BY group?

1 point

if Last.JobTitle;

where First.JobTitle=1;

where Last.JobTitle=1;

if First.JobTitle;

9.
Question 9
Which statement needs to be added to the DATA step to reset the value of Total for each new BY group?

12345678
data RegionTotal;
set Sales;
by Region;
… ADD STATEMENT HERE …
Total+Sales;
if Last.Region=1 then output;
run;

1 point

Total=0;

if First.Region=1 then Total=0;

if First.Region=0 then Total=0;

if Last.Region=0 then Total=0;
10.
Question 10
What are the values for First.City and Last.City for the third row of the input table given the following information?

1234
data StatePopulation;
set Population;
by State City;
run;
1 point

First.City=1 and Last.City=1

First.City=0 and Last.City=0

First.City=1 and Last.City=0

First.City=0 and Last.City=1

 

Week- 3

Manipulating Data with Functions

1.
Question 1
Functions and CALL routines both return a value that must be used in an assignment statement or expression.

1 point

True

False

2.
Question 2
Which function calculates the average of the columns Week1, Week2, Week3, and Week4?

1 point

mean(of Week1, Week4)

mean(Week1-Week4)

mean(of Week1-Week4)

mean(Week1, Week4)

3.
Question 3
Which expression rounds each value of Sales to the nearest hundredth (or two decimal places)?

1 point

round(Sales, 2)

round(Sales, .01)

round(Sales, dollar10.2)

round(Sales)

4.
Question 4
Which function could be used to remove the non-numeric symbols in Phone?

1 point

COMPBL

COMPRESS

SCAN

FIND

5.
Question 5
Which statement reads CityCountry and correctly assigns a value to Country?

1 point

Country=scan(CityCountry, 2, ‘, ‘);

Country=scan(CityCountry, -1);

Country=scan(CityCountry, 2, ‘,’);

Country=scan(CityCountry, 2);

6.
Question 6
Which expression creates CityCountry?

1 point

cats(“, “, City, Country)

cat(City, “, “, Country)

catx(“, “, City, Country)

catx(City, “, “, Country)

7.
Question 7
How many rows are written to output based on the following statement?

if find(Location, “Oahu”, “i”) > 0 then output;

1 point

1

0

5

3

8.
Question 8
Which of the following functions can convert the values of the numeric variable Level to character values?

1 point

put(3., Level)

put(Level, 3.)

input(3., Level)

input(Level, 3.)

9.
Question 9
Which of the following functions converts the character values of Base to numeric values?

1 point

put(comma10.2, Base)

put(Base, comma10.2)

input(Base, comma10.2)

input(comma10.2, Base)

10.
Question 10
Which step is not required when converting a character column named Date to a numeric SAS date column with the same name?

1 point

Specify an appropriate informat in the INPUT function.

Format the new numeric Date column.

Use the INPUT function to read the renamed CharDate character column and create a numeric column named Date.

Rename the Date column to a new name, such as CharDate.

 

 

Week- 4

Creating and Using Custom Formats

1.
Question 1
Which of the following contains valid syntax?

1 point

12
value $grades. ‘A’=’Excellent’
‘B’=’Good’;

12
value qtrfmt 1,2,3=’First’
4,5,6=’Second’;

12
value qtrfmt ‘1’-‘3’=’First’
‘4’-‘6’=’Second’;

12
value grades ‘A’=’Excellent’
‘B’=’Good’;

2.
Question 2
What is the formatted value for the value of 100 given the following step?

6
proc format;
value rates 1-<100=’low’
100<-<200=’medium’
200-300 =’high’
other =’out of range’;
run;
1 point

medium

out of range

high

low

3.
Question 3
In the FORMAT procedure, you specify the name of the format and the name of the column that will use the custom format.

1 point

True

False

4.
Question 4
What is the correct formatted output given the following PROC FORMAT step and the input table?

12345
proc format;
value $answer ‘1’=’Yes’
‘2’=’No’
‘other’=’Not Answered’;
run;

1 point

5.
Question 5
Which of the following does not have proper syntax for specifying a range in the VALUE statement?

1 point

‘A’ – ‘C’

500-<700

500>-700

‘Horse’ – ‘Mouse’

6.
Question 6
Which statement is true concerning options for the FORMAT procedure?

1 point

The FMTLIB option specifies the library to store the format.

The CNTLIN= option specifies a table from which formats are built.

The FMTLIB option goes in the SELECT statement.

The CNTLIN= option goes in the VALUE statement.

7.
Question 7
Which columns are required in an input table to create a format based on numeric ranges?

1 point

FMTNAME, START, END, and LABEL

FORMAT, START, LAST, NAME, and TYPE

FORMAT, START, END, and NAME

FMTNAME, START, and LABEL

8.
Question 8
Which option in the PROC FORMAT statement specifies a library to store a custom format?

1 point

LIBRARY=

STORE=

CATALOG=

FMTLIB=

9.
Question 9
What is the default search order that is used to locate formats?

1 point

WORK.FORMATS > LIBRARY.FORMATS

SASHELP.FORMATS > LIBRARY.FORMATS

SASHELP.FORMATS > WORK.FORMATS

LIBRARY.FORMATS > WORK.FORMATS

10.
Question 10
Which of the following contains valid syntax for the FMTSEARCH= option?

1 point

options fmtsearch=sashelp;

options fmtsearch=[sashelp.fmts sashelp];

options fmtsearch=sashelp.formats;

options fmtsearch=(sashelp sashelp.fmts);

 

 

Week- 5

Combining Tables

1.
Question 1
Which statement is true concerning concatenating tables?

1 point

All tables must have the same number of columns.

Missing values are generated for columns that exist in one input table and not in another.

Columns in all tables must have matching names and lengths.

Tables must be in the same library.

2.
Question 2
Which statement renames the existing column Location in work.travel as Destination?

1 point

set vacations travel(rename=(Location=Destination));

set vacations travel(rename(Destination=Location));

set vacations(rename=(Location=Destination)) travel;

set vacations travel(rename=(Destination=Location));

3.
Question 3
Which statement is true concerning merging with matching rows?

1 point

Only two input tables can be specified in the MERGE statement.

The MERGE statement must refer to temporary input tables.

The columns in the BY statement can be in only one of the tables.

The input tables must be sorted by the columns in the BY statement.

4.
Question 4
How many rows are in the both output table given the following input tables and code?

12345
data both;
merge agetable
foodtable;
by Name;
run;
1 point

two

four

three

five

5.
Question 5
How many rows are in the empsauc output table given the following input tables and code?

12345
data empsauc;
merge empsau phonec;
by EmpID;
run;

1 point

four

three

two

five

6.
Question 6
What is the result of the following step?

1234
data combine;
merge donors1 donors2;
by ID;
run;
1 point

The step fails because the BY column ID is not properly sorted.

The table combine is created with four columns and five rows.

The step fails because Units is in both tables and not the BY column.

The step fails because of duplicate ID values within the donors1 table.

7.
Question 7
Which statement best describes the rows in the output table?

123456
data bonuses;
merge managers(in=M)
staff(in=S);
by EmpID;
if M=0 and S=1;
run;
1 point

only the rows from managers that have no match in staff

only the rows from staff that have no match in managers

all the matching and nonmatching rows from both managers and staff

all the matching rows from both managers and staff

8.
Question 8
What are the values of C and A during the third iteration of the DATA step?

12345
data client_amount;
merge clients(in=C)
amounts(in=A);
by Name;
run;
1 point

C=1 and A=0

C=0 and A=0

C=0 and A=1

C=1 and A=1

9.
Question 9
What is the value of Location in the output table?

1234
data locALL;
merge loc1 loc2 loc3;
by Code;
run;
1 point

France

Italy

Belgium

France Belgium Italy

10.
Question 10
You can use one DATA step to merge the following three tables:

1 point

True

False

 

 

Week- 6

Processing Repetitive Code

1.
Question 1
Which output table does the following step produce?

6
data Earnings(keep=Qtr Earned);
Amount=1000; Rate=.075/4;
do Qtr=1 to 4;
Earned+(Amount+Earned)*Rate;
end;
run;
1 point

2.
Question 2
Which statement is true regarding the iterative DO loop?

DO index-column = start TO stop <BY increment>;

1 point

The index column is not in the final table unless specifically kept.

The index column is incremented at the bottom of each DO loop.

The start and stop values can be character or numeric values.

If an increment value is not specified, the default increment is 0.

3.
Question 3
How many rows are in the savings output table given the following input table and code? Note: Amount is a numeric column.

12345678910
data work.savings;
set pg2.savings;
Savings=0;
do Year=1 to 5;
do qtr=1 to 4;
Savings+Amount;
Savings+(Savings*0.02/12);
end;
end;
run;
1 point

20

5

4

1

4.
Question 4
What is the final value of Year given the following step?

123456
data invest;
do Year=2010 to 2019;
Capital+5000;
Capital+(Capital*.03);
end;
run;
1 point

. (missing)

2020

2019

2010

5.
Question 5
Which of the following statements contains valid syntax?

1 point

do while (Year>2025);

do 1 to 10 by 2;

do date=’01JAN2019′ to ’31JAN2019′;

do until Earnings<=100000;

6.
Question 6
How many rows are in the bikeinfo2 output table given the following input table and code?

123456789
data bikeinfo2;
set bikeinfo;
do month=1 to 3;
do week=1 to 4;
bike=bike+2;
end;
output;
end;
run;
1 point

3

6

24

12

2

7.
Question 7
What is the value of x at the completion of the DATA step?

123456
data test;
x=15;
do until(x>12);
x+1;
end;
run;
1 point

16

. (missing)

13

15

8.
Question 8
Which statement is false?

1 point

The DO UNTIL loop executes until a condition is true.

The DO UNTIL loop checks the condition at the bottom of the loop.

The DO WHILE loop checks the condition at the top of the loop.

The DO WHILE loop always executes at least one time.

9.
Question 9
Which of the following statements contains valid syntax?

1 point

do Year=2018 to 2018 or until (Earnings<=100000);

do week=1 to 52 do until (Mileage ge 2750);

do Age=10 to 14 and while (Weight<150);

do Increase=5 to 10 while (temperature Lt 102);

10.
Question 10
Which output table does the following step produce?

123456
data test;
bike=10;
do day=1 to 7 while (bike lt 13);
bike=bike+2;
end;
run;
1 point

 

 

Week- 7

Restructuring Tables

1.
Question 1
Which is the better description for the following table?

1 point

wide table

narrow table

2.
Question 2
When using the DATA step to go from a wide table to a narrow table, which statement is needed for creating multiple rows from a single row?

1 point

OUTPUT

WIDE

RETAIN

NARROW

3.
Question 3
How many rows will be in the final table if work.airwide contains three rows?

12345678910111213
data work.airnarrow;
set work.airwide;
Month=’Jan’;
Air=Jan;
output;
Month=’Feb’;
Air=Feb;
output;
Month=’Mar’;
Air=Mar;

1 point

12

9

6

3

4.
Question 4
When using the DATA step to go from a narrow table to a wide table, the KEEP statement is needed to hold values in the PDV across multiple iterations of the DATA step.

1 point

True

False

5.
Question 5
Which statement needs to be added to the DATA step to include only the last row per value of Year in the output table?

123456789
data work.airwide2(keep=Year Jan Feb Mar);
set work.airnarrow;
by Year;
retain Jan Feb Mar;
if Month=’Jan’ then Jan=Air;
else if Month=’Feb’ then Feb=Air;
else if Month=’Mar’ then Mar=Air;
… insert statement here …
run;
1 point

if Last.Year=0 then output;

output;

if Last.Year=1 then output;

if Last then output;

6.
Question 6
Which statement is false concerning the TRANSPOSE procedure?

1 point

Use a BY statement to sort the data while transposing.

Use a VAR statement to specify the character and numeric columns to transpose.

By default, numeric columns are transposed.

Columns are transposed into rows.

7.
Question 7
Which statements are needed in a PROC TRANSPOSE step for the following example (narrow to wide)?

1 point

123
by Day;
id Meal;
var Food;

123
by Day;
id Food;
var Meal;

12
by Day;
var Meal Food;

12
id Day;
var Food Meal;
8.
Question 8
Which statement or statements are needed in a PROC TRANSPOSE step for the following example (wide to narrow)?

1 point

12
id Day;
var Breakfast Lunch Dinner;

1
id Day;

1
var Breakfast Lunch Dinner;

1
by Day;
9.
Question 9
Which option is needed in the PROC TRANSPOSE statement to rename the _NAME_ column as shown in the output table?

1 point

rename=Meal

prefix=Meal

_name_=Meal

name=Meal

10.
Question 10
Which option is needed in the PROC TRANSPOSE statement to rename the COL columns as shown in the output table?

1 point

out=meals2(prefix=(COL1=Day7 COL2=Day1))

out=meals2(name=(COL1=Day7 COL2=Day1))

out=meals2(COL1=Day7 COL2=Day1)

out=meals2(rename=(COL1=Day7 COL2=Day1))

 

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *