DSCI 325 Practice Midterm Questions Spring In SAS, a statement must end

Similar documents
work.test temp.test sasuser.test test

DSCI 325: Handout 15 Introduction to SAS Macro Programming Spring 2017

DSCI 325: Handout 9 Sorting and Options for Printing Data in SAS Spring 2017

Linux Tutorial #4. Redirection. Output redirection ( > )

MATH& 146 Lesson 8. Section 1.6 Averages and Variation

DSCI 325: Handout 4 If-Then Statements in SAS Spring 2017

SAS Training Spring 2006

Stat 302 Statistical Software and Its Applications SAS: Working with Data

DSCI 325: Handout 10 Summarizing Numerical and Categorical Data in SAS Spring 2017

Part A. What is the output of the following code segments? Write the output to the right. Note that there is only output for the print statements.

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

Checking for Duplicates Wendi L. Wright

STATION

Introduction to SAS Mike Zdeb ( , #61

MATH 707-ST: Introduction to Statistical Computing with SAS and R. MID-TERM EXAM (Writing part) Fall, (Time allowed: TWO Hours)

Name Geometry Intro to Stats. Find the mean, median, and mode of the data set. 1. 1,6,3,9,6,8,4,4,4. Mean = Median = Mode = 2.

Introduction to the SAS Macro Facility

DSCI 325: Handout 2 Getting Data into SAS Spring 2017

Introduction to DATA Step Programming: SAS Basics II. Susan J. Slaughter, Avocet Solutions

Introduction to DATA Step Programming SAS Basics II. Susan J. Slaughter, Avocet Solutions

Intermediate SAS: Working with Data

Introduction to DATA Step Programming SAS Basics II. Susan J. Slaughter, Avocet Solutions

Contents. About This Book...1

Examples of Using the ARGV Array. Loop Control Operators. Next Operator. Last Operator. Perl has three loop control operators.

From Manual to Automatic with Overdrive - Using SAS to Automate Report Generation Faron Kincheloe, Baylor University, Waco, TX

INSTRUCTIONS FOR FACULTY USER MANUAL CENTRE FOR PROFESSIONAL STUDIES. 1 P age

DSCI 325: Handout 6 More on Manipulating Data in SAS Spring 2017

Lecture 1 Getting Started with SAS

Introduction to SAS Statistical Package

DSCI 325: Handout 3 Creating and Redefining Variable in SAS Spring 2017

Name: Batch timing: Date: The SAS data set named WORK.SALARY contains 10 observations for each department, currently ordered by DEPARTMENT.

Formats and the Format Procedure

STAT:5400 Computing in Statistics

Cody s Collection of Popular SAS Programming Tasks and How to Tackle Them

Using Data Set Options in PROC SQL Kenneth W. Borowiak Howard M. Proskin & Associates, Inc., Rochester, NY

SAS Online Training: Course contents: Agenda:

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes

Epidemiology Principles of Biostatistics Chapter 3. Introduction to SAS. John Koval

Click on the GradeMark icon for the paper where the comment is to be added (see illustration below).

SSID User Guide and Policy

CS 1713 Introduction to Programming II

(Tests = 40%) + (Assignments = 40%) + (Participation = 20%) = (Quarter Final Grade)

INFORMATION VISUALIZATION

SAS Institue EXAM A SAS Base Programming for SAS 9

CS 1713 Introduction to Programming II

Graded Project. Excel 2016

Contents. Overview How SAS processes programs Compilation phase Execution phase Debugging a DATA step Testing your programs

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research

ECLT 5810 SAS Programming - Introduction

SAS Data Libraries. Definition CHAPTER 26

THIS IS NOT REPRESNTATIVE OF CURRENT CLASS MATERIAL. STOR 455 Midterm 1 September 28, 2010

Introductory Guide to SAS:

Biostatistics & SAS programming. Kevin Zhang

DATA Step Debugger APPENDIX 3

The information here will help you avoid violating university policy about copying material written by others.

Using an ICPSR set-up file to create a SAS dataset

Example1D.1.sas. * Procedures : ; * 1. print to show the dataset. ;

proc print data=account; <insert statement here> run;

Midterm spring. CSC228H University of Toronto

Getting Your Data into SAS The Basics. Math 3210 Dr. Zeng Department of Mathematics California State University, Bakersfield

ssh tap sas913 sas

CMU MSP : SAS FORMATs and INFORMATs Howard Seltman October 15, 2017

Basic Concept Review

Click on the GradeMark icon for the paper where the comment is to be added (see illustration below).

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

An Introduction to SAS University Edition

BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS. What is SAS History of SAS Modules available SAS

ASSIGNMENT #2 ( *** ANSWERS ***) 1

CMU MSP : SAS FORMATs and INFORMATs Howard Seltman Nov. 7+12, 2018

1) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed?

FSEDIT Procedure Windows

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 10 Notes. Class URL:

Accessing Data and Creating Data Structures. SAS Global Certification Webinar Series

More on Lists, Dictionaries Introduction to File I/O CS 8: Introduction to Computer Science Lecture #10

15-110: Principles of Computing, Spring 2018

SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

IT 1003 Introduction to Programming (New)

Blackboard Learn Grade Integration with Banner

Please write your answers clearly and neatly we can t give you credit if we can t decipher what you ve written.

Overview of Data Management Tasks (command file=datamgt.sas)

Exam Name: SAS Base Programming for SAS (r) 9 Exam Type: SAS Exam Code: A Total Questions: 127

Math 155. Measures of Central Tendency Section 3.1

SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapters 9, 11 & 12. By Tasha Chapman, Oregon Health Authority

ACCESSDATA SUPPLEMENTAL APPENDIX

Chapter 3: Working With Your Data

Reading data in SAS and Descriptive Statistics

ACCESS for ELLs 2.0 Paper Grade 1 Sample Items

USING SAS SOFTWARE TO COMPARE STRINGS OF VOLSERS IN A JCL JOB AND A TSO CLIST

CMSC 201 Spring 2016 Lab 04 For Loops

STAT 7000: Experimental Statistics I

INTRODUCTION SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006)

Exam Name: SAS Base Programming for SAS 9

Going Under the Hood: How Does the Macro Processor Really Work?

Chapter 2: Frequency Distributions

SAS Macro Language: Reference

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

CITS. mycourses Grade Book & Grading Forms

Blackboard 9 - Creating Categories in the Grade Center

Beginning Tutorials DATE HANDLING IN THE SAS SYSTEM. Bruce Gilsen, Federal Reserve Board

Transcription:

DSCI 325 Practice Midterm Questions Spring 2016 1. In SAS, a statement must end a. with a colon b. with a semicolon c. in a new line d. with the command RUN 2. Which of the following is a valid variable name in SAS? a. Var.5 b. 5var c. Var_5 d. Var/5 3. Which of the following is not true about the work library in SAS? a. It is the default library where a data set is stored if no other library is specified. b. It is a library that comes pre-installed with SAS. c. It is equivalent to the sasuser library. d. Data sets in the work library are removed from this library upon exiting a SAS session. 4. Suppose you have the following data lines. Ronald Reagan 01-20-198101-21-1985Republican George Bush 01-20-1989 Republican William J. Clinton01-20-199301-20-1997Democratic George W. Bush 01-20-200101-20-2005Republican Barack Obama 01-20-200901-21-2013Democratic Which INPUT statement is the best for reading in the data? a. INPUT Name $ FirstInaugDate $ SecondInaugDate $ Party $; b. INPUT Name $ 1-18 FirstInaugDate $ 19-28 SecondInaugDate $ 29-38 Part $ 39-48; c. INPUT Name $ 1-18 FirstInaugDate MMDDYY10. SecondInaugDate MMDDYY10. Party $ 39-48; d. INPUT Name :$18. FirstInaugDate :$10. SecondInaugDate :$10. Party $ 39-48; 5. Which of the following SAS functions works on character variables? a. MEAN b. SUM c. LENGTH 1

6. The SAS informat $16. indicates a. A date in the year 2016 b. A monetary value having field width 16 c. A numeric value to 16 decimal places d. A character variable with width 16 7. In SAS, newly created variables based on variables already in a data file a. must be named in the INPUT statement. b. must be created with other numeric variables only (i.e., not with other character variables). c. are not printed out when the resulting data set is printed. d. can be created within the DATA step. 8. Consider the following four names used to create a SAS data set: work.test temp.test sasuser.test test How many of these will be stored as permanent data sets? a. None b. One c. Two d. Three 9. Suppose the following program is run in SAS. DATA fruits; INPUT fruit1 $ fruit2 $; Apple kiwi grape orange mango lemon pear banana PROC PRINT; Which of the following is the resulting output? a. c. b. d. 2

10. Suppose the following program is run in SAS (note the use of @@ in the INPUT statement). DATA fruits; INPUT fruit1 $ fruit2 $ @@; Apple kiwi grape orange mango lemon pear banana PROC PRINT; Which of the following is the resulting output? a. c. b. d. 11. Suppose the following program is run in SAS. DATA test; INPUT Name $ var1 var2; IF (var1 LT 5 OR var1 GE 10) THEN var3 = var1 + var2; ELSE var3 = var1 - var2; Jim 4 6 Sam 7 10 Angie 12 8 ; PROC PRINT; Sketch in the results in the table below that would appear in the Results Viewer window. 3

12. Consider the following SAS Program which reads in Vehicle Identification Numbers (VINs) and creates two new variables, Make and Features, based on the VIN. DATA VehicleIDs; INPUT VIN $; Make = SUBSTR(VIN, 2, 1); Features = SUBSTR(VIN, 4, 5); 1F1JF27W86J178227 4S4BP67C454326624 ; PROC PRINT; a. Sketch in the results in the table below that would appear in the Results Viewer window b. The model year of a vehicle is contained in the 10 th position of the VIN. Write a statement that creates a new variable named ModelYear that pulls off the 10 th position from the VIN. ModelYear = c. The features of a vehicle are described in the last six digits of the VIN. Write a statement that creates a new variable named Features that pulls off the last six digits from the VIN. Features = 4

13. Suppose the following program is submitted to read in a data set containing students scores. DATA Grades; INPUT Student HW1 HW2 HW3 Quiz1 Quiz2 Quiz3 Midterm Final; Tim 9 10 9 4 3 3 32 30 Sarah 8 7 6 3 4 4 30 32 John 9 8 8 4 4 3 37 32 Kara 10 10 10 5 4 5 38 39 ; PROC PRINT; When this code was submitted, the following output was produced. The Log window displayed the following: a. Explain why the Grades data set was not successfully created in SAS. (2 pts) b. Complete the INPUT statement below to successfully read in the data. (2 pts) INPUT 5

14. Consider the Grades data set from the previous problem. Suppose that an instructor wanted to write a SAS program that would assign grades as follows: 90% and above is an A, 80% and above (but less than 90%) is a B, 70% and above (but less than 80%) is a C, etc. The instructor wrote the following program to do this. DATA Grades; INPUT Student $ HW1 HW2 HW3 Quiz1 Quiz2 Quiz3 Midterm Final; PointsEarned = HW1 + HW2 + HW3 + Quiz1 + Quiz2 + Quiz3 + Midterm + Final; Percent = PointsEarned / 125 ; IF Percent GE.90 then Grade = 'A'; IF (Percent GE.80 AND Percent LT.90) then Grade = 'B'; IF (Percent GE.70 AND Percent LT.80) then Grade = 'C'; IF (Percent GE.60 AND Percent LT.70) then Grade = 'D'; ELSE Grade = 'F'; Tim 9 10 9 4 3 3 32 30 Sarah 8 7 6 3 4 4 30 32 John 9 8 8 4 4 3 37 32 Kara 10 10 10 5 4 5 38 39 ; PROC PRINT; The instructor was surprised to see the results, which are given below (there were no errors in the Log window). Rewrite the middle portion of the code in the box below to produce the desired outcome. (3 pts) DATA Grades; INPUT Student $ HW1 HW2 HW3 Quiz1 Quiz2 Quiz3 Midterm Final; PointsEarned = HW1 + HW2 + HW3 + Quiz1 + Quiz2 + Quiz3 + Midterm + Final; Percent = PointsEarned / 125 ; 6

15. Data from the file people.txt was used to create a SAS data set named people. The file and SAS code are shown below. DATA people; INFILE 'D:\Desktop\people.txt'; INPUT Name $ Age Gender $; In the same session of SAS and after submitting the above program (so the SAS data set named people exists in the work library), you decide to create a permanent data set named people2 to be stored in the sasuser library. You use the following code. DATA sasuser.people2; SET work.people; INPUT Name $ Age Gender $; The program fails to run, and SAS returns the following in the log window. Rewrite the code (in the box on the right) to successfully create the people2 data set to be stored in the sasuser library. (3 pts) Original Code: New Code: DATA sasuser.people2; SET work.people; INPUT Name $ Age Gender $; 7

16. Which statement is correct concerning the merging of data sets? a. The MERGE statement must refer to permanent data sets. b. The variables in the BY statement can be in only one of the data sets. c. Only two data sets can be specified in the MERGE statement. d. When you use the MERGE statement with the BY statement, the data must be sorted or indexed on the BY variable. 17. The following SAS log was created after running a program to merge two data sets. Note that the first data set contains 77 observations and the second contains 148 observations. Explain why the final merged data set contains more observations than either of the original data sets. 18. Consider the following code which is used to merge two data sets named products and costs. Write the appropriate IF statement to create the desired data set containing only nonmatches. DATA products_costs; MERGE products(in=inprod) costs(in=incost); by ID; 19. Two SAS data sets need to be merged, but the BY variables have different names. What can be done to enable the data sets to be merged? 8

20. Explain the difference between appending, concatenating, and merging data sets. 21. Consider the original data set named Emps. Suppose you run a program to append the three data sets Emps2008, Emps2009, and Emps2010 to this original file. a. How many observations will be in Emps after appending the three data sets? b. How many variables will be in Emps after appending the three data sets? 22. Consider the original data sets named EmpsCN and EmpsJP. Suppose you run a program to concatenate these data sets to create a new file named EmpsA112. How many variables will be in EmpsA112? Program to concatenate: 9

23. Which method would you use if you wanted to create a new variable at the time of concatenation? a. APPEND procedure b. SET statement 24. Which DATA step correctly references the macro variable SYSDATE? a. title "February Trials as of &sysdate"; data drg.febtrial; set drg.trial; if month=2 and year=2013; b. title 'February Trials as of sysdate'; data drg.febtrial; set drg.trial; if month=2 and year=2013; 25. Which of the following statements creates a macro variable named site with a value of 75? a. let site='75'; b. &let site=75; c. %let site=75; d. %let site='75'; 26. Write a statement below that creates a macro variable named rate that has a value of satisfactory. 27. The following %LET statement creates the macro variable name with a value of prod. %let name=prod; Write a DATA statement that combines a macro variable reference to name with a prefix to create the SAS data set Reg.Newprod. 10

28. Which DATA step below correctly references the macro variable site? The value of site is used to create the data set name Westprod as well as to select observations for which the value of region is west. a. %let site=west; data &site.prod; set reg.productn; if region='&site'; b. %let site=west; data &site.prod; set reg.productn; if region="&site"; c. %let site=west; data &siteprod; set reg.productn; if region='&site'; 11