DSCI 325: Handout 4 If-Then Statements in SAS Spring 2017
|
|
- Thomas Wood
- 6 years ago
- Views:
Transcription
1 DSCI 325: Handout 4 If-Then Statements in SAS Spring 2017 IF-THEN STATEMENTS IN SAS We have already worked briefly with IF-THEN statements in SAS. Here, we will discuss using IF-THEN statements in a DATA step to assign a value to a variable using one (or more) condition(s). Note that an IF-THEN statement takes on the following general form. IF condition THEN action; For example, consider once again the Grades data set. Suppose that the professor uses the following statements to calculate a final percentage grade for each student and to determine whether they pass or fail the course. Identify the condition and the action in each of the IF- THEN statements in the following code. FinalPercent = SUM(TotalQuiz,TotalExam,EC,Final)/640; IF FinalPercent >=.70 THEN Status = 'Pass'; IF FinalPercent <.70 THEN Status = 'Fail'; PROC PRINT Data=Grades2; VAR FirstName LastName FinalPercent Status; Note that for each observation in the data set, when SAS sees the keyword IF it evaluates the condition to determine whether it is true or false. If the condition is true, SAS takes the action that follows the keyword THEN. If the condition is false, SAS ignores the THEN clause and simply proceeds to the next statement in the DATA step. A portion of the result of the PROC PRINT is shown below: 1
2 The condition in an IF-THEN statement typically involves the use of a comparison operator (such as greater than or equal to as was used above). SAS uses the following syntax for the standard comparison operators. Note that you can use either syntax when programming. Comparison SAS syntax using symbols SAS syntax using Mnemonic Equivalent Less than < LT Greater than > GT Less than or equal to <= LE Greater than or equal to >= GE Equal to = EQ Not equal to ^= or ~= NE Equal to one of a list IN( ) Change the IF-THEN statements in the above code to the following and verify that they work. IF FinalPercent GE.70 THEN Status = 'Pass'; IF FinalPercent LT.70 THEN Status = 'Fail'; USING DO and END STATEMENTS The IF-THEN statements discussed thus far allow only one action to take place. If multiple actions need to take place if the condition is true, then you should use DO and END statements. Typical IF Statement (one action) IF condition THEN action; IF Statement using DO and END (multiple actions) IF condition THEN DO; action 1; action 2; END; Consider the following example that has two action statements. Town = SUBSTR(ZipTownAreaCode,7,ParenLocation-8); IF SUBSTR(Town,1,1) EQ 'A' THEN DO; ATown=1; BTown=0; END; 2
3 Discuss what the IF statement should do in detail. Consider the print-out from the above code. Is this what you expected? Task: This dataset contains only towns that start with an A or B. Modify the code so that all B towns are given a value of 1 for BTown and 0 for ATown (instead of leaving them missing as was done above). Town = SUBSTR(ZipTownAreaCode,7,ParenLocation-8); IF SUBSTR(Town,1,1) EQ 'A' THEN DO; ATown=1; BTown=0; END; 3
4 IF-THEN-ELSE Statements Next, note that the IF-THEN statement tells SAS what to do when the condition is true. To tell SAS what action to take when the condition is false, you could utilize an ELSE statement. For example, we could have also created the variable Status as follows. FinalPercent = SUM(TotalQuiz,TotalExam,EC,Final)/640; IF FinalPercent >=.70 THEN Status = 'Pass'; ELSE Status = 'Fail'; PROC PRINT Data=Grades2; VAR FirstName LastName FinalPercent Status; Task: Recall the example from the previous page. Use an ELSE statement to modify the code so that all B towns are given a value of 1 for BTown and 0 for ATown.). Town = SUBSTR(ZipTownAreaCode,7,ParenLocation-8); IF SUBSTR(Town,1,1) EQ 'A' THEN DO; ATown=1; BTown=0; END; 4
5 Problems with Missing Data Suppose that one of the students was ill and was unable to take the final exam as scheduled. In the data file Grades_missing.csv, this student s final exam score is a missing value. Read this file into your personal library and run code similar to the following. What happens? DATA Grades3; SET Hooks.Grades_missing; FinalPercent = SUM(TotalQuiz,TotalExam,EC,Final)/640; IF FinalPercent >=.70 THEN Status = 'Pass'; ELSE Status = 'Fail'; PROC PRINT Data=Grades3; VAR FirstName LastName FinalPercent Status; Note: The SUM function returns the sum of all of the non-missing arguments, so SAS still calculates a value for FinalPercent. Alternatively, consider calculating FinalPercent as follows. DATA Grades3; SET Hooks.Grades_missing; FinalPercent = (TotalQuiz + TotalExam + EC + Final)/640; IF FinalPercent >=.70 THEN Status = 'Pass'; ELSE Status = 'Fail'; Note: The + operator returns a missing value if any of the arguments are missing. 5
6 Also, note that SAS considers a missing value to be smaller than any other numerical value. Thus, it is always a good idea to program for missing values as shown below. DATA Grades3; SET Hooks.Grades_missing; FinalPercent = (TotalQuiz + TotalExam + EC + Final)/640; IF FinalPercent =. THEN Status = ' '; ELSE IF FinalPercent >=.70 THEN Status = 'Pass'; ELSE Status = 'Fail'; Questions: 1. Run this program. Is this the result you expected? 2. Why did you get this result? 3. Add one statement to the DATA step to fix this problem. DATA Grades3; SET Hooks.Grades_missing; SUM(Quiz1,Quiz2,Quiz3,Quiz4,Quiz5,Quiz6,Quiz7,Quiz8,Quiz9, Quiz10,Quiz11,Quiz12); FinalPercent = (TotalQuiz + TotalExam + EC + Final)/640; IF FinalPercent =. THEN Status = ' '; ELSE IF FinalPercent >=.70 THEN Status = 'Pass'; ELSE Status = 'Fail'; 6
7 Using Logical Operators in IF-THEN Statements In addition to comparison operators, we can also use logical operators when writing a condition for an IF-THEN statement. Operation SAS syntax using symbols SAS syntax using Mnemonic Equivalent All conditions must be true & AND At least one condition must be true or! OR Reverse the logic of a condition ^ or ~ NOT For example, we could assign grades to the students in the file Grades.csv as follows. FinalPercent = SUM(TotalQuiz,TotalExam,EC,Final)/640; IF (FinalPercent >= 0.90) THEN Grade='A'; IF (FinalPercent >= 0.80) AND (FinalPercent < 0.90) THEN Grade='B'; IF (FinalPercent >= 0.70) AND (FinalPercent < 0.80) THEN Grade='C'; IF (FinalPercent >= 0.60) AND (FinalPercent < 0.70) THEN Grade='D'; IF (FinalPercent < 0.60) THEN Grade='F'; PROC PRINT Data=Grades2; VAR FirstName LastName Final FinalPercent Grade; Comment: Though it is not necessary, it is good practice to write programs that are easy to read (the earlier you develop this habit, the better off you ll be). For example, in the above code, the conditions and actions have been aligned, and optional parentheses have been used above to offset the conditions. These statements create the following data set (only a portion is shown here). 7
8 Task: Now, suppose the instructor wants to give bonus points to students who show some sign of improvement from the beginning of the course to the end of the course. Suppose that two percentage points will be added to a student's final percentage grade if either their Exam 1 grade is less than their Exam 3 and Final grade or their Exam 2 grade is less than their Exam 3 and Final grade. Call this new variable FinalPercent_Adjusted. Finish the following SAS code to do this, and verify that your program works. FinalPercent = SUM(TotalQuiz,TotalExam,EC,Final)/640; 8
9 A Word of Caution Regarding IF-THEN Statements Be careful when using multiple IF-THEN statements when creating a new variable. For example, suppose we tried to assign grades to the students in the file Grades_missing.csv as follows. DATA Grades3; SET Hooks.Grades_missing; FinalPercent = (TotalQuiz + TotalExam + EC + Final)/640; IF FinalPercent=. THEN Grade='Incomplete'; IF FinalPercent >= 0.90 THEN Grade='A'; IF FinalPercent >= 0.80 AND FinalPercent < 0.90 THEN Grade='B'; IF FinalPercent >= 0.70 AND FinalPercent < 0.80 THEN Grade='C'; IF FinalPercent >= 0.60 AND FinalPercent < 0.70 THEN Grade='D'; IF FinalPercent < 0.60 THEN Grade='F'; PROC PRINT Data=Grades3; VAR FirstName LastName Final FinalPercent Grade; SAS creates the following data set (only a portion is shown here). Question: Is this the result you expected? What is the problem? 9
10 Note that SAS checks each IF statement, and the value for Grade is overwritten each time a condition is met. Any change in the order of the statements may affect the results. USING ELSE-IF STATEMENTS A better idea is to use IF-THEN-ELSE statements. The general form is as follows: IF condition THEN action; ELSE IF condition THEN action; ELSE IF condition THEN action; This way, once a condition is met, SAS stops checking the other IF-THEN statements that follow ELSE. This not only prevents you from writing over values but is also much more efficient. The correct program is shown below. DATA Grades3; SET Hooks.Grades_missing; FinalPercent = (TotalQuiz + TotalExam + EC + Final)/640; IF FinalPercent=. THEN Grade='Incomplete'; ELSE IF FinalPercent >= 0.90 THEN Grade='A'; ELSE IF FinalPercent >= 0.80 THEN Grade='B'; ELSE IF FinalPercent >= 0.70 THEN Grade='C'; ELSE IF FinalPercent >= 0.60 THEN Grade='D'; ELSE IF FinalPercent < 0.60 THEN Grade='F'; PROC PRINT Data=Grades3; VAR FirstName LastName Final FinalPercent Grade; A portion of the results is shown below. 10
11 Comment: The last ELSE statement in a series may simply specify an action that is automatically executed for all observations that fail to satisfy any of the previous IF-THEN statements. IF condition THEN action; ELSE IF condition THEN action; ELSE action; For example, we could have modified the above program as follows: DATA Grades3; SET Hooks.Grades_missing; FinalPercent = (TotalQuiz + TotalExam + EC + Final)/640; IF FinalPercent=. THEN Grade='Incomplete'; ELSE IF FinalPercent >= 0.90 THEN Grade='A'; ELSE IF FinalPercent >= 0.80 THEN Grade='B'; ELSE IF FinalPercent >= 0.70 THEN Grade='C'; ELSE IF FinalPercent >= 0.60 THEN Grade='D'; ELSE Grade='F'; PROC PRINT Data=Grades3; VAR FirstName LastName Final FinalPercent Grade; 11
12 Task: Consider the following SAS code. DATA test; INPUT ID Gender $ Score; DATALINES; 1 male 21 2 male 34 3 male 54 4 male 76 5 female 44 6 female 21 7 female 22 8 female 17 ; DATA test2; SET test; IF Score < 30 THEN Group = 1; IF Gender = 'male' then Group = 2; PROC PRINT DATA=test2; Predict the value of Group for each observation and write it in the table below. Then, run the program to verify your answer. Now, suppose the code is changed to the following: DATA test2; SET test; IF Score < 30 THEN Group = 1; ELSE IF Gender = 'male' then Group = 2; PROC PRINT DATA=test2; 12
13 Once again, predict the value of Group for each observation and write it in the table below. Then, run the program to verify your answer. Finally, consider changing the code as follows and predict the output. Run the program in SAS to check your answer. DATA test2; SET test; IF Gender = 'male' THEN Group = 2; ELSE IF Score < 30 then Group = 1; PROC PRINT DATA=test2; To avoid errors in your programs, make sure you understand how SAS deals with a series of IF- THEN or IF-THEN-ELSE statements! 13
14 IF-THEN STATEMENTS AND CHARACTER VALUES Consider again the Grades.csv data set. The following code is used to create a new variable named Ada. The code assigns a 1 to this variable if the town is Ada and a. if the town is not Ada. Town = SUBSTR(ZipTownAreaCode,7,ParenLocation-8); IF Town = 'Ada' THEN Ada=1; PROC PRINT DATA=Grades2; Var FirstName LastName ZipTownAreaCode ParenLocation Town Ada; Comment #1: SAS is case-sensitive with regard to the string of text. For example, try to replace the above IF-THEN statement with the following: IF Town = 'ADA' THEN Ada=1; What happens? Comment #2: This code does NOT work if you have leading or trailing spaces (which you cannot see) in your variable name. For example, in the following code, town contains a leading space. Thus, in the first observation, Town is specified by _Ada, not Ada. As a result, the IF statement fails to recognize _Ada as Ada and thus does not assign Ada a value of 1. Town = SUBSTR(ZipTownAreaCode,6,ParenLocation-7); IF Town = 'Ada' THEN Ada=1; PROC PRINT DATA=Grades2; Var FirstName LastName ZipTownAreaCode ParenLocation Town Ada; 14
15 The following program verifies this. Town = SUBSTR(ZipTownAreaCode,6,ParenLocation-7); IF Town = 'Ada' THEN Ada=1; TownLength = Length(Town); Test = '*' Town; PROC PRINT DATA=Grades2; Var FirstName LastName ZipTownAreaCode ParenLocation Town Ada TownLength Test; You can remove any character (including a space) using the COMPRESS function in SAS. The first argument is the string with which you want to work; the second argument in the COMPRESS function is the character you d like to remove. Town = COMPRESS(SUBSTR(ZipTownAreaCode,6,ParenLocation-7),' '); IF Town = 'Ada' THEN Ada=1; TownLength = Length(Town); Test = '*' Town; PROC PRINT DATA=Grades2; VAR FirstName LastName ZipTownAreaCode ParenLocation Town Ada TownLength; 15
16 Note that the COMPRESS function removes ALL spaces, which is not desirable here because now any town with two words has its space removed (e.g., Albert_Lea is now AlbertLea). A better alternative is to use the STRIP function in SAS, which removes leading and trailing blanks from a string. Town = STRIP(SUBSTR(ZipTownAreaCode,6,ParenLocation-7)); IF Town = 'Ada' THEN Ada=1; TownLength = Length(Town); Test = '*' Town; PROC PRINT DATA=Grades2; VAR FirstName LastName ZipTownAreaCode ParenLocation Town Ada TownLength Test; 16
17 Tasks: 1. Suppose we d like to create a variable named NotAda which takes on the value 1 for all towns NOT EQUAL to Ada and 0 otherwise. Write a program to do this. 2. Write a program which creates a variable named ATown which takes on the value 1 if the town is either Ada, Adams, or Adolph and 0 otherwise. 3. SAS has an IN operator that can be used to accomplish the previous task. The IN operator allows you to check a condition using a list. Verify that the following code produces the same output as your code for Task 2. Town = SUBSTR(ZipTownAreaCode,7,ParenLocation-8); IF Town IN ('Ada','Adams', 'Adolph') THEN ATown=1; 4. Modify your code from Task 2 so that all towns that start with an A are given a value of 1 for ATown and 0 otherwise. 17
DSCI 325: Handout 6 More on Manipulating Data in SAS Spring 2017
DSCI 325: Handout 6 More on Manipulating Data in SAS Spring 2017 CREATING VARIABLES IN SAS: A WRAP-UP As you have already seen several times, SAS variables can be created with an assignment statement in
More informationDSCI 325: Handout 3 Creating and Redefining Variable in SAS Spring 2017
DSCI 325: Handout 3 Creating and Redefining Variable in SAS Spring 2017 Content Source: The Little SAS Book, Chapter 3, by L. Delwiche and S. Slaughter. CREATING NEW VARIABLES OR REDEFINING VARIABLES In
More informationControl Structures. CIS 118 Intro to LINUX
Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true
More informationproc print data=account; <insert statement here> run;
Statistics 6250 Name: Fall 2012 (print: first last ) Prof. Fan NetID #: Midterm Three Instructions: This is an in-class and open book midterm. You must write your answers on the provide spaces. Give concise
More informationChapter 3: Working With Your Data
Chapter 3: Working With Your Data Creating variables based on other variables is easily done within the data step. Assignment is carried out with the = sign. Example: INPUT var1 var2 var3; mysum = var1
More informationSAS Training Spring 2006
SAS Training Spring 2006 Coxe/Maner/Aiken Introduction to SAS: This is what SAS looks like when you first open it: There is a Log window on top; this will let you know what SAS is doing and if SAS encountered
More informationSAS seminar. The little SAS book Chapters 3 & 4. April 15, Åsa Klint. By LD Delwiche and SJ Slaughter. 3.1 Creating and Redefining variables
SAS seminar April 15, 2003 Åsa Klint The little SAS book Chapters 3 & 4 By LD Delwiche and SJ Slaughter Data step - read and modify data - create a new dataset - performs actions on rows Proc step - use
More informationEECS2301. Special variables. $* and 3/14/2017. Linux/Unix part 2
Warning: These notes are not complete, it is a Skelton that will be modified/add-to in the class. If you want to us them for studying, either attend the class or get the completed notes from someone who
More informationexample: name1=jan name2=mike export name1 In this example, name1 is an environmental variable while name2 is a local variable.
Bourne Shell Programming Variables - creating and assigning variables Bourne shell use the set and unset to create and assign values to variables or typing the variable name, an equal sign and the value
More informationDSCI 325: Handout 24 Introduction to Writing Functions in R Spring 2017
DSCI 325: Handout 24 Introduction to Writing Functions in R Spring 2017 We have already used several existing R functions in previous handouts. For example, consider the Grades dataset. Once the data frame
More informationStat 302 Statistical Software and Its Applications SAS: Working with Data
1 Stat 302 Statistical Software and Its Applications SAS: Working with Data Fritz Scholz Department of Statistics, University of Washington Winter Quarter 2015 February 26, 2015 2 Outline Chapter 7 in
More informationبسم اهلل الرمحن الرحيم
بسم اهلل الرمحن الرحيم Fundamentals of Programming C Session # 10 By: Saeed Haratian Fall 2015 Outlines Examples Using the for Statement switch Multiple-Selection Statement do while Repetition Statement
More informationERROR: ERROR: ERROR:
ERROR: ERROR: ERROR: Formatting Variables: Back and forth between character and numeric Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then
More informationIntroduction to SAS Mike Zdeb ( , #61
Mike Zdeb (402-6479, msz03@albany.edu) #61 FORMAT, you can design informats for reading and interpreting non-standard data, and you can design formats for displaying data in non-standard ways....example
More informationSAS Programming Basics
SAS Programming Basics SAS Programs SAS Programs consist of three major components: Global statements Procedures Data steps SAS Programs Global Statements Procedures Data Step Notes Data steps and procedures
More informationDSCI 325: Handout 15 Introduction to SAS Macro Programming Spring 2017
DSCI 325: Handout 15 Introduction to SAS Macro Programming Spring 2017 The Basics of the SAS Macro Facility Macros are used to make SAS code more flexible and efficient. Essentially, the macro facility
More informationLecture 1 Getting Started with SAS
SAS for Data Management, Analysis, and Reporting Lecture 1 Getting Started with SAS Portions reproduced with permission of SAS Institute Inc., Cary, NC, USA Goals of the course To provide skills required
More informationDSCI 325: Handout 9 Sorting and Options for Printing Data in SAS Spring 2017
DSCI 325: Handout 9 Sorting and Options for Printing Data in SAS Spring 2017 There are a handful of statements (TITLE, FOOTNOTE, WHERE, BY, etc.) that can be used in a wide variety of procedures. For example,
More informationPROC MEANS for Disaggregating Statistics in SAS : One Input Data Set and One Output Data Set with Everything You Need
ABSTRACT Paper PO 133 PROC MEANS for Disaggregating Statistics in SAS : One Input Data Set and One Output Data Set with Everything You Need Imelda C. Go, South Carolina Department of Education, Columbia,
More informationIntroduction (SPSS) Opening SPSS Start All Programs SPSS Inc SPSS 21. SPSS Menus
Introduction (SPSS) SPSS is the acronym of Statistical Package for the Social Sciences. SPSS is one of the most popular statistical packages which can perform highly complex data manipulation and analysis
More informationSTAT 7000: Experimental Statistics I
STAT 7000: Experimental Statistics I 2. A Short SAS Tutorial Peng Zeng Department of Mathematics and Statistics Auburn University Fall 2009 Peng Zeng (Auburn University) STAT 7000 Lecture Notes Fall 2009
More informationMEHMET YAYAN - İSMAİL HAKKI ÖZTÜRK CS101/SEC.-2 CLASS NOTES 1. March 28-30, 2007
MEHMET YAYAN - İSMAİL HAKKI ÖZTÜRK CS101/SEC.-2 CLASS NOTES 1 March 28-30, 2007 if Single-Selection Statement The conditional statement in Java has the form if (condition) statement The condition must
More informationDSCI 325 Practice Midterm Questions Spring In SAS, a statement must end
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
More informationbash Execution Control COMP2101 Winter 2019
bash Execution Control COMP2101 Winter 2019 Bash Execution Control Scripts commonly can evaluate situations and make simple decisions about actions to take Simple evaluations and actions can be accomplished
More informationTitle:[ Variables Comparison Operators If Else Statements ]
[Color Codes] Environmental Variables: PATH What is path? PATH=$PATH:/MyFolder/YourStuff?Scripts ENV HOME PWD SHELL PS1 EDITOR Showing default text editor #!/bin/bash a=375 hello=$a #No space permitted
More informationChecking for Duplicates Wendi L. Wright
Checking for Duplicates Wendi L. Wright ABSTRACT This introductory level paper demonstrates a quick way to find duplicates in a dataset (with both simple and complex keys). It discusses what to do when
More informationDSCI 325: Handout 10 Summarizing Numerical and Categorical Data in SAS Spring 2017
DSCI 325: Handout 10 Summarizing Numerical and Categorical Data in SAS Spring 2017 USING PROC MEANS The routine PROC MEANS can be used to obtain limited summaries for numerical variables (e.g., the mean,
More informationSAM Ad-Hoc. Gives direct, near unrestricted (view-only) access to your SAM database Ability to see raw data with queries created by you.
SAM Ad-Hoc Gives direct, near unrestricted (view-only) access to your SAM database Ability to see raw data with queries created by you. Four Clauses of a Query SELECT Describes the columns that will be
More informationCPSC 411, 2015W Term 2 Midterm Exam Date: February 25, 2016; Instructor: Ron Garcia
CPSC 411, 2015W Term 2 Midterm Exam Date: February 25, 2016; Instructor: Ron Garcia This is a closed book exam; no notes; no calculators. Answer in the space provided. There are 8 questions on 14 pages,
More informationDecision Control Structure. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan
Decision Control Structure DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) Decision control
More informationConditional Control Structures. Dr.T.Logeswari
Conditional Control Structures Dr.T.Logeswari TEST COMMAND test expression Or [ expression ] Syntax Ex: a=5; b=10 test $a eq $b ; echo $? [ $a eq $b] ; echo $? 2 Unix Shell Programming - Forouzan 2 TEST
More informationINTRODUCTION SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006)
INTRODUCTION To SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006) 1 Getting Started with SAS SAS stands for Statistical Analysis System. SAS is a computer software
More informationAn Easy Route to a Missing Data Report with ODS+PROC FREQ+A Data Step Mike Zdeb, FSL, University at Albany School of Public Health, Rensselaer, NY
SESUG 2016 Paper BB-170 An Easy Route to a Missing Data Report with ODS+PROC FREQ+A Data Step Mike Zdeb, FSL, University at Albany School of Public Health, Rensselaer, NY ABSTRACT A first step in analyzing
More informationDSCI 325: Handout 1 Introduction to SAS Programs Spring 2017
DSCI 325: Handout 1 Introduction to SAS Programs Spring 2017 SAS (which originally stood for Statistical Analysis System) was started in 1976 and since this time has become an industry standard in the
More informationRESTRICTING AND SORTING DATA
RESTRICTING AND SORTING DATA http://www.tutorialspoint.com/sql_certificate/restricting_and_sorting_data.htm Copyright tutorialspoint.com The essential capabilities of SELECT statement are Selection, Projection
More informationRecognition of Tokens
Recognition of Tokens Lecture 3 Section 3.4 Robb T. Koether Hampden-Sydney College Mon, Jan 19, 2015 Robb T. Koether (Hampden-Sydney College) Recognition of Tokens Mon, Jan 19, 2015 1 / 21 1 A Class of
More informationProblem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur
Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 15 Branching : IF ELSE Statement We are looking
More informationDEMO A Language for Practice Implementation Comp 506, Spring 2018
DEMO A Language for Practice Implementation Comp 506, Spring 2018 1 Purpose This document describes the Demo programming language. Demo was invented for instructional purposes; it has no real use aside
More informationShell programming. Introduction to Operating Systems
Shell programming Introduction to Operating Systems Environment variables Predened variables $* all parameters $# number of parameters $? result of last command $$ process identier $i parameter number
More informationChecking Multiple Conditions
Checking Multiple Conditions Conditional code often relies on a value being between two other values Consider these conditions: Free shipping for orders over $25 10 items or less Children ages 3 to 11
More informationIntroduction to SPSS on the Macintosh. Scott Patterson,Ph.D. Broadcast and Electronic Communication Arts San Francisco State University.
Introduction to SPSS on the Macintosh. Scott Patterson,Ph.D. Broadcast and Electronic Communication Arts San Francisco State University Spring 2000 This is a brief guide to using SPSS in the Macintosh
More informationTemplate Language and Syntax Reference
APPENDIX B This chapter describes the language and syntax conventions used in the VPN Solutions Center template implementation. Grammar and Syntax The Extensible Markup Language (XML) template definition
More informationChapter 2, Part I Introduction to C Programming
Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,
More information(Extract) JCL. MVS - OS/390 - z/os. Michel Castelein - Arcis Services 14 May
JCL MVS - OS/390 - z/os Michel Castelein - Arcis Services 14 May 2009 arcis@advalvasbe http://wwwarcis-servicesnet JOB COND parameter //jobname JOB CLASS=n,MSGCLASS=n, // COND={rc-test (rc-test[,rc-test]
More informationWelcome to Top 10 SAS Functions
Welcome to Top 10 SAS Functions Goal and Agenda By the end of this meeting, you will understand 10 key SAS functions purpose, value and features. What are SAS functions? Why use them? Use Case Manipulating
More informationDSCI 325: Handout 2 Getting Data into SAS Spring 2017
DSCI 325: Handout 2 Getting Data into SAS Spring 2017 Data sets come in many different formats. In some situations, data sets are stored on paper (e.g., surveys) and other times data are stored in huge
More informationRemove this where. statement to produce the. report on the right with all 4 regions. Retain this where. statement to produce the
Problem 4, Chapter 14, Ex. 2. Using the SAS sales data set, create the report shown in the text. Note: The report shown in the text for this question, contains only East & West region data. However, the
More informationProjects for Compilers
Projects for Compilers 1. Project One: Lexical Analysis (Required) (1) Directions Implement a transition-diagram-based lexical analysis for the programming language TINY. (2) Outputs Source code (implemented
More informationIntroduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions
Introduction to SAS Procedures SAS Basics III Susan J. Slaughter, Avocet Solutions SAS Essentials Section for people new to SAS Core presentations 1. How SAS Thinks 2. Introduction to DATA Step Programming
More informationFundamentals of Programming Session 9
Fundamentals of Programming Session 9 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationC Programming for Engineers Structured Program
C Programming for Engineers Structured Program ICEN 360 Spring 2017 Prof. Dola Saha 1 Switch Statement Ø Used to select one of several alternatives Ø useful when the selection is based on the value of
More informationDr. Khaled Al-Qawasmi
Al-Isra University Faculty of Information Technology Department of CS Programming Mathematics using MATLAB 605351 Dr. Khaled Al-Qawasmi ١ Dr. Kahled Al-Qawasmi 2010-2011 Chapter 3 Selection Statements
More informationAUTUMN BREAK HOLIDAYS HOME WORK ( ) CLASS XI
KV, AFS CAMPUS, GURGAON AUTUMN BREAK HOLIDAYS HOME WORK (2016-17) CLASS XI INFORMATICS PRACTICES 1. Solve Unit Test-2 Exam in the notebook. 2. Presentation on the given topics according to the Roll numbers:
More informationCreating New Variables in JMP Datasets Using Formulas Exercises
Creating New Variables in JMP Datasets Using Formulas Exercises Exercise 3 Calculate the Difference of Two Columns 1. This Exercise will use the data table Cholesterol. This data table contains the following
More informationCondition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.
Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes
More informationCreation of SAS Dataset
Creation of SAS Dataset Contents SAS data step Access to PC files Access to Oracle Access to SQL 2 SAS Data Step Contents Creating SAS data sets from raw data Creating and managing variables 3 Creating
More informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
More informationECLT 5810 SAS Programming - Introduction
ECLT 5810 SAS Programming - Introduction Why SAS? Able to process data set(s). Easy to handle multiple variables. Generate useful basic analysis Summary statistics Graphs Many companies and government
More informationIntroduction 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 SAS Essentials Section for people new to SAS Core presentations 1. How SAS Thinks 2. Introduction to DATA Step
More informationCSCI Compiler Design
CSCI 565 - Compiler Design Spring 2015 Midterm Exam March 04, 2015 at 8:00 AM in class (RTH 217) Duration: 2h 30 min. Please label all pages you turn in with your name and student number. Name: Number:
More informationIntroduction 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 SAS Essentials Section for people new to SAS Core presentations 1. How SAS Thinks 2. Introduction to DATA Step Programming
More information4.6.5 Data Sync User Manual.
4.6.5 Data Sync User Manual www.badgepass.com Table of Contents Table of Contents... 2 Configuration Utility... 3 System Settings... 4 Profile Setup... 5 Setting up the Source Data... 6 Source Filters...
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2017 EXAMINATIONS CSC 104 H1S Instructor(s): G. Baumgartner Duration 3 hours PLEASE HAND IN No Aids Allowed Student Number: Last (Family)
More informationIntermediate SAS: Working with Data
Intermediate SAS: Working with Data OIT Technical Support Services 293-4444 oithelp@mail.wvu.edu oit.wvu.edu/training/classmat/sas/ Table of Contents Getting set up for the Intermediate SAS workshop:...
More informationFortran 90 Two Commonly Used Statements
Fortran 90 Two Commonly Used Statements 1. DO Loops (Compiled primarily from Hahn [1994]) Lab 6B BSYSE 512 Research and Teaching Methods The DO loop (or its equivalent) is one of the most powerful statements
More informationCD Assignment I. 1. Explain the various phases of the compiler with a simple example.
CD Assignment I 1. Explain the various phases of the compiler with a simple example. The compilation process is a sequence of various phases. Each phase takes input from the previous, and passes the output
More informationFSEDIT Procedure Windows
25 CHAPTER 4 FSEDIT Procedure Windows Overview 26 Viewing and Editing Observations 26 How the Control Level Affects Editing 27 Scrolling 28 Adding Observations 28 Entering and Editing Variable Values 28
More informationMidterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009
Midterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009 April 16, 2009 Instructions: Please write your answers on the printed exam. Do not turn in any extra pages. No interactive electronic devices
More information(Refer Slide Time: 01:12)
Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl
More informationGE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004
GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout
More informationNavigating in SPSS. C h a p t e r 2 OBJECTIVES
C h a p t e r 2 Navigating in SPSS 2.1 Introduction and Objectives As with any new software program you may use, it is important that you are able to move around the screen with the mouse and that you
More informationEssential Skills for Bioinformatics: Unix/Linux
Essential Skills for Bioinformatics: Unix/Linux SHELL SCRIPTING Overview Bash, the shell we have used interactively in this course, is a full-fledged scripting language. Unlike Python, Bash is not a general-purpose
More informationExpressions. Definitions CHAPTER 12
131 CHAPTER 12 Expressions Definitions 131 SAS Constants in Expressions 132 Definition 132 Character Constants 132 Using Quotation Marks 132 Comparing Character Constants and Character Variables 133 Hexadecimal
More information22/10/16. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS
DATA CODING IN SPSS STAFF TRAINING WORKSHOP March 28, 2017 Delivered by Dr. Director of Applied Economics Unit African Heritage Institution Enugu Nigeria To code data in SPSS, Lunch the SPSS The Data Editor
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 24, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater A note on awk for (item in array) The order in which items are returned
More informationCSE 374 Midterm Exam 11/2/15. Name Id #
Name Id # There are 8 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More informationChapter 3: The IF Function and Table Lookup
Chapter 3: The IF Function and Table Lookup Objectives This chapter focuses on the use of IF and LOOKUP functions, while continuing to introduce other functions as well. Here is a partial list of what
More informationScripting. More Shell Scripts. Adapted from Practical Unix and Programming Hunter College
Scripting More Shell Scripts Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss Back to shell scripts Now that you've learned a few commands and can edit files,
More informationSAS Online Training: Course contents: Agenda:
SAS Online Training: Course contents: Agenda: (1) Base SAS (6) Clinical SAS Online Training with Real time Projects (2) Advance SAS (7) Financial SAS Training Real time Projects (3) SQL (8) CV preparation
More informationCSCE 120: Learning To Code
CSCE 120: Learning To Code Organizing Code I Hacktivity 9.1 Introduction Prior to engaging in this hacktivity, you should have completed all of the pre-class activities as outlined in this module. At the
More informationComputer Systems and Architecture
Computer Systems and Architecture Stephen Pauwels UNIX Scripting Academic Year 2018-2019 Outline Basics Conditionals Loops Advanced Exercises Shell Scripts Grouping commands into a single file Reusability
More informationLab - 8 Awk Programming
Lab - 8 Awk Programming AWK is another interpreted programming language which has powerful text processing capabilities. It can solve complex text processing tasks with a few lines of code. Listed below
More informationChapter 6: Modifying and Combining Data Sets
Chapter 6: Modifying and Combining Data Sets The SET statement is a powerful statement in the DATA step. Its main use is to read in a previously created SAS data set which can be modified and saved as
More informationA Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers
A Big Step Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Copyright 2006 2009 Stewart Weiss What a shell really does Here is the scoop on shells. A shell is a program
More informationDavid Beam, Systems Seminar Consultants, Inc., Madison, WI
Paper 150-26 INTRODUCTION TO PROC SQL David Beam, Systems Seminar Consultants, Inc., Madison, WI ABSTRACT PROC SQL is a powerful Base SAS Procedure that combines the functionality of DATA and PROC steps
More informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationDiscussion 12 The MCE (solutions)
Discussion 12 The MCE (solutions) ;;;;METACIRCULAR EVALUATOR FROM CHAPTER 4 (SECTIONS 4.1.1-4.1.4) of ;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS ;;;from section 4.1.4 -- must precede def of
More informationFundamentals of Programming Session 8
Fundamentals of Programming Session 8 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationUsing C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :
Programming Assignment - 3 Due Date : Section 2 - Monday October 1 st, 2018 - No Later than 12:45 pm Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private
More informationCSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have
CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have been covered in the first 5 weeks of the course. The exam
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationCMPS115 Winter 2004 Exam #2 OPEN BOOK/NOTE WORK ALONE (NO TEAMS) COVERS: Lectures 6 17
1. Coupling Example (20 pts) Given a set a modules that print or store student status reports, with data-flow connections as shown in the diagram and table below (arrow direction is In flow, and Out flow
More informationScripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers
Scripting Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss What a shell
More informationINFOB3TC Exam 2. Sean Leather. Monday, 30 January 2012, 17:00 20:00
Department of Information and Computing Sciences Utrecht University INFOB3TC Exam 2 Sean Leather Monday, 30 January 2012, 17:00 20:00 1 Preliminaries The exam consists of 8 pages (including this page).
More informationLab 2 Supplement: Programming in Stata Short Course on Poverty & Development for Nordic Ph.D. Students University of Copenhagen June 13-23, 2000
Lab 2 Supplement: Programming in Stata Short Course on Poverty & Development for Nordic Ph.D. Students University of Copenhagen June 13-23, 2000 To take full advantage of the strengths of Stata, it s work
More informationFundamentals of Programming Session 4
Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).
More informationGradebook - Grades Tab Create Assignment
Gradebook - Grades Tab Create Assignment If no assignments have been created for the selected class in the selected term, the student names will not display. No Grades Found will be displayed where the
More informationUNIX shell scripting
UNIX shell scripting EECS 2031 Summer 2014 Przemyslaw Pawluk June 17, 2014 What we will discuss today Introduction Control Structures User Input Homework Table of Contents Introduction Control Structures
More informationStat 302 Statistical Software and Its Applications SAS Functions
1 Stat 302 Statistical Software and Its Applications SAS Functions Fritz Scholz Department of Statistics, University of Washington Winter Quarter 2015 February 14, 2015 2 Creating New Variables Here we
More informationShell Scripting. Todd Kelley CST8207 Todd Kelley 1
Shell Scripting Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 If we have a set of commands that we want to run on a regular basis, we could write a script A script acts as a Linux command,
More information