Earthquake data in geonet.org.nz

Size: px
Start display at page:

Download "Earthquake data in geonet.org.nz"

Transcription

1 Earthquake data in geonet.org.nz There is are large gaps in the 2012 and 2013 data, so let s not use it. Instead we ll use a previous year. Go to At the screen, click on the CLEAR button, so that it doesn t assume you want data from last week, last month, or last year. Then enter in a date range starting in If your birthday is December 10, then use December 10, 2010 to January 09, SAS Programming September 11, / 72

2 Earthquake data in geonet.org.nz Towards the bottom of the page, click on the botton that says Build Query instead of Show of Map. This way, it will generate a data file for you. Use the drop-down menu to select CSV as the file format. SAS Programming September 11, / 72

3 Earthquake data After you click the search button, you should be given a url for a website where you can download the data as a.csv file. If it opens up automatically in Excel, I recommend closing Excel without saving. Instead get the file from your Downloads or Desktop or wherever it was saved so that Excel doesn t change anything. SAS Programming September 11, / 72

4 Earthquake An alternative is to download a dataset I ve downloaded of all earthquakes from January 1st, 2010 to January 30th, 2011, and extract the month that you need. The dataset has about observations, and it will be up to you to figure out how to get the exact dates you need. You could, for example, open in Excel to figure out which rows you need, then use firstobs= and obs= in SAS to get just those rows. In linux you can do this $ grep " " quake csv > AugSep.csv $ grep " " quake csv >> AugSep.csv This will grab all lines in the files that have earthquakes in August into a file, then append that file with all earthquakes in September. SAS Programming September 11, / 72

5 Earthquake A quick way to determine the line number that your data should start with is this, assuming that your birthday is say, August 15th. $ nl quake csv > foo $ grep " " foo head -1 $ grep " " foo tail -1 Here nl creates a version of the file with line numbers in the first column, and this saved to the file foo, which you can later delete. The first grep and head will spit out the first line in foo that has your birthday. The second grep and tail will spit out the last line that has an event in the month starting on your birthday. SAS Programming September 11, / 72

6 Earthquake data I tried uploading a file with 5000 lines of earthquakes in SAS Studio, and this worked fine. SAS Programming September 11, / 72

7 Earthquake data I tried uploading a file with 5000 lines of earthquakes in SAS Studio, and this worked fine. SAS Programming September 11, / 72

8 Earthquake data I tried uploading a file with 5000 lines of earthquakes in SAS Studio, and this worked fine. SAS Programming September 11, / 72

9 The SUM statement Because the data step processes one observation at a time, it can be awkward to write functions of an entire column of data unless using a special procedure like PROC MEANS. The SUM statement is a helpful way around this to create a counter or cumulutive sum in a data set. SAS Programming September 11, / 72

10 SUM statements The idea with the sum statement is to have a new variable which is a counter, and which is usually incremented conditionally. As an example, we ll keep track of the number of cars that have more than 100,000 miles in the cars.txt data set. SAS Programming September 11, / 72

11 SUM statement with cars.txt dataset SAS Programming September 11, / 72

12 SUM Statement Some new aspects of the code are the syntax of using high + 1 defines a new variable and have it increment by 1 each time the condition is true. In most languages, you would write something like high = high +1 instead, but that doesn t work and just creates missing values the SUM function can also be used but requires the variable high to be initialized first, so here just gives 1 for every nonmissing value SAS Programming September 11, / 72

13 SUM statement with cars.txt dataset SAS Programming September 11, / 72

14 SUM statement with cars.txt dataset 21:00 Monday, September 8, SAS Programming September 11, / 72

15 SUM and RETAIN statements with cars.txt dataset You can fix previous code with a retain statement to initialize variables SAS Programming September 11, / 72

16 SUM and RETAIN statements with cars.txt dataset Note the order of the columns. The RETAIN statement effects the order of the columns defined in this datastep, but additional RETAIN statements won t change the order of the variables read in from the SET statement. SAS Programming September 11, / 72

17 MIN and RETAIN statements with cars.txt dataset What will this do? Notice that lag1() returns the value of the variable in the previous observation. SAS Programming September 11, / 72

18 MIN and RETAIN statements with cars.txt dataset Notice that the MIN function behaves intelligently for missing values it returns missing only when all values are missing. The minimjm of a missing value and a nonmissing value is the nonmissing value. minmiles returns the minimum value encountered so far for the value of year. SAS Programming September 11, / 72

19 First and Last observations for a given category (Chapter 24). Often we want to only output one value for each level of a given category. For example, I might only want to know the minimum mileage for each model year of the cars. Or I might want to know how many cars there were in a given year, with one observation per car. In a medical setting, it is common to have datasets with patientid as one variable with one record per doctor visit. The number of visits per patient can vary widely, so sometimes it is useful to summarize this with a dataset with one record (observation) per patientid. For this one record, you might want to keep track of, for example, the total number of visits, the sum of the fees for all visits, or the time of the most recent visit. For medical information, you might want to keep track of the highest blood pressure recorded on all visits. SAS Programming September 11, / 72

20 First and Last observations We ll practice using the car data again. Let s create a dataset that has the year and the minimum mileage for that year. If you use a BY statement after a SET statement in a data set, SAS creates internal variables that start with FIRST. and LAST.. These allow you to determine when a variable in the last one of its category (assuming the data is already sorted on the same BY variable). SAS Programming September 11, / 72

21 First and Last observations SAS Programming September 11, / 72

22 First and Last observations SAS Programming September 11, / 72

23 First and Last observations Here is simpler code that doesn t use the lag1 function. However, it is a bit less general and assumes more sorting. With the lag1 function, I could keep track of both the minimum and maximum at the same time and put those into the data set on one row. SAS Programming September 11, / 72

24 First and Last observations SAS Programming September 11, / 72

25 Example with Earthquake data: related to next homework! As an example, we ll use some earthquake data from New Zealand. This data set was downloaded from which has a database of New Zealand earthquakes. You specify a geographic range (using latitude and longitude) and a time frame. These were all earthquakes recorded from Jan 1st to March 31st in There were 4892 recorded earthquakes in that interval. The goal here will be to keep a cumulative count of the number of earthquakes that were at least 4.0 on the Richter Scale. The data is sorted decreasing by time, and we want it to be sorted increasing by time. SAS Programming September 11, / 72

26 Cumulative sums: Earthquake data The data comes as a.csv file. It is hard to read by eye as a plain text file, but easy to read into computer programs like SAS. SAS Programming September 11, / 72

27 Cumulative sums: Earthquake data Here is what part of it looks like read into Excel. Several variables on the right were chopped off. As is typical for empirical data, the data set includes many variables that you might not be interested in. SAS Programming September 11, / 72

28 Dates and Times in the earthquake data Something a little tricky about the earthquake data is that the times are not in a standard format. They have a T in the middle separating dates from hours, minutes, and seconds, and they have a Z at the end. There are different things you could do to deal with this. You could replace T and Z with spaces in the original data file and hope that this doesn t interfere with other variables such as eventtype. I m not really sure a good way to do this without linux tools. In emacs I would do a global replace of T with a space, and it would tell me how many replacements took place, which, if it is 2 per observation and there are no missing values, then it worked. What we ll do as a SAS solution is to read in the dates as character strings, but only read the first 10 characters, and this will chop off the hour-minute-second information. We ll have to convert the string to a date (an integer), which can be done using the input() function. SAS Programming September 11, / 72

29 SAS code for dealing with earthquake times SAS Programming September 11, / 72

30 SAS code for dealing with earthquake times SAS Programming September 11, / 72

31 input() function The input function can also be used to convert a string iwith commas for large numbers into a numeric value. For example data popsize; input population $9.; pop=input(population,comma9.); datalines; 2,115,353 ; run; It is often convenient to be able go back and forth between thinking of a value as either a string or a number. SAS Programming September 11, / 72

32 Earthquake counter SAS Programming September 11, / 72

33 Earthquake counter SAS Programming September 11, / 72

34 More on First and Last observations for a given value SAS Programming September 11, / 72

35 More on First and Last observations for a given value SAS Programming September 11, / 72

36 More on First and Last observations for a given value SAS Programming September 11, / 72

37 More on First and Last observations for a given value SAS Programming September 11, / 72

38 More on First and Last observations for a given value SAS Programming September 11, / 72

39 Example: average of top three salaries For one retirement plan at UNM, employees are given a proportion of the average of their top three years of salary, where the proportion depends on the number of years of service. Here we want to determine which three years have the highest salary for each employee and get the average salary for those three years. How can you do this in SAS? SAS Programming September 11, / 72

40 Example: average of top three salaries A bit tricky: need a RETAIN so that high3 is not missing. SAS Programming September 11, / 72

41 Example: average of top three salaries After sorting on ID and SALARY (not on year), we want a counter to rank the salaries for each ID. SAS Programming September 11, / 72

42 Example: average of top three salaries Here we used a subsetting IF to only include the observation with the average of the top three salaries. SAS Programming September 11, / 72

43 Example: average of top three salaries How could we have done this if salaries were in ascending order instead? In this case you could use LAST.ID to determine the highest salary. You could also LAG1 and LAG2 to determine previous salaries (second and third highest). You d have some code that looked something like this salary1 = lag1(salary); salary2 = lag2(salary); highest3 = mean(salary,salary1,salary2); if last.id; This code also assumes that each individual has at least three years worth of salary, which might be a reasonable assumption if the person qualifies for retirement, but still something to be careful about. SAS Programming September 11, / 72

44 Example: average of top three salaries SAS Programming September 11, / 72

45 A caution about LAG functions Use of LAGS can be very useful but can be a tricky when they are used conditionally (in IF or WHILE statements). The safest way of using them is to create a variable which is the lagged variable, and then do more sophisticated stuff with them. The following code generates incorrect output (but not errors) SAS Programming September 11, / 72

46 Imitating SAS in R The following code imitates the first.id and last.id variables in SAS, and I use it on the cars data set. SAS Programming September 11, / 72

47 Imitating SAS in R SAS Programming September 11, / 72

48 Imitating SAS in R SAS Programming September 11, / 72

49 DO loops An important part of programming is loops. SAS automatically loops through datasets that are read in and processes each observation one at a time. However, sometimes you need to control loops yourself, create loops without reading in data, loop through subsets of a dataset, and so forth. SAS Programming September 11, / 72

50 DO loops In the previous example, the data step generated simulated normal random variables and outputted them to the dataset called n01 because it was Normal(0,1) values. The value in parentheses is the random number seed. You will get different values depending on the seed, which allows you to reproduce results or generate new results. The syntax requires that the DO loop be closed with END; which you can think of as being like a closing parentheses. SAS Programming September 11, / 72

51 DO loops To get into SAS s head so to speak, consider the following code and try to anticipate what it does. The data set address.txt has three observations (the addresses used for Homework problem 1.2). SAS Programming September 11, / 72

52 Using DO to create plots Note that log is the natural log. SAS Programming September 11, / 72

53 Using DO to create plots This plot is not very good. Axis labels are too small, title is oddly large, and there is no legend. But blue is for odds, and orange is for log-odds. SAS Programming September 11, / 72

54 Using DO with LAG functions Some recursive problems can be solved using LAG functions within DO loops. An example from Ross, A First Course in Probability Chapter 2, is: Let f n denote the number of ways of tossing a coint n times such that successive heads never appear. Argue that f n = f n 1 + f n 2 n 2, where f 0 1, f 1 2 HINT: How many outcomes are there that start with a head, and how many that start with a tail? If P n denotes the probability that successive heads never appear when a coin is tossed n times, find P n (in terms of f n ) when all possible outcomes of the n tosses are equally likely. Compute P 10. SAS Programming September 11, / 72

55 Using DO with LAG functions The recursion f n = f n 1 + f n 2 works for the first term because if the first toss is tails, then we have n 1 tosses without restrictions, and there are f n 1 ways to not get successive heads with the remaining tosses. If the first toss is heads, the second toss must be tails (if n > 2), so there are now n 2 tosses without restrictions, and there are f n 2 ways to accomplish this. The probability of not getting successive heads in n tosses is therefore P n = f n /2 n, since each of the 2 n sequences of tosses is equally likely. To compute this, we use a LAG function within a DO loop. SAS Programming September 11, / 72

56 Using DO with LAG functions SAS Programming September 11, / 72

57 Using DO with LAG functions SAS Programming September 11, / 72

58 Using DO with LAG functions This code doesn t work, and the problem seems to be putting the LAG function in an IF statement. SAS Programming September 11, / 72

59 DO WHILE You can also DO something conditionally until you have the desired number of successes or observations. Suppose I want to simulate normal random variables conditional on having values greater than 3. I might want to use this to get, say the median of X X > 3, which is not easy to deal with analytically. The following accomplishes this, although it is somewhat inefficient. To do this more efficiently, you could use importance sampling. SAS Programming September 11, / 72

60 DO WHILE caution Because the condition that you require might never occur or might take a very long time to execute, your program could run a VERY long time and appear to be hanging, creating an infinite loop or just very long loop. If we wanted 1000 observations of standard normal variables being larger than 3, we d need generate an average of 740,000 random numbers. If we wanted 1000 normal variables being larger than 6, we d need to generate an average of 1,013,594,635,000 random variables, which probably wouldn t work, and you might need something more efficient like importance sampling. If you aren t sure whether something will take too long, you could add a counter and stop after a maximum number of iterations. SAS Programming September 11, / 72

61 DO WHILE testing SAS Programming September 11, / 72

62 DO UNTIL testing An alternative approach is to use DO UNTIL which executes the code in the block first, then tests the condition to see whether it should continue to execute. It is mostly a matter of style whether you use DO WHILE or DO UNTIL. For both DO WHILE and DO UNTIL, infinite loops are easy to mistakenly creep into your code. A DO WHILE will be an infinite loop if the condition is always true, and a DO UNTIL will be an infinite loop if the condition is always false. The following uses a DO UNTIL instead of DO WHILE to get the same results. SAS Programming September 11, / 72

63 LEAVE and CONTINUE with DO loops In addition to testing at the top (WHILE) or bottom (UNTIL) of a loop, you can break out of a loop using the LEAVE and CONTINUE statements. With the LEAVE statement, you break out of the DO loop entirely and move past the END statement. For the CONTINUE statement, you return to the top of the loop to do the next iteration of the loop. This is an alternative to putting extra testing conditions in the WHILE or UNTIL conditions. SAS Programming September 11, / 72

64 LEAVE and CONTINUE SAS Programming September 11, / 72

65 CONTINUE Continue will mostly be useful if you have more complicated loops where there is computational savings if you jump to the next iteration once you have done everything needed. This can also be useful for running an example with many iterations, but only printing a few of them. In Markov chain Monte Carlo experiments for example, you might want to run a Markov chain for several million iterations, but this is too many to plot. Instead of plotting each iteration, you could just plot every 1000th iteration. This is most easily achieved with the MODULUS function, mod(), which returns the remainder when divided by the modulus. The modulus function can also be useful for separating a dataset into its odd and even observations numbers, or some other unusual grouping. SAS Programming September 11, / 72

66 CONTINUE example with modulus SAS Programming September 11, / 72

67 MODULUS example SAS Programming September 11, / 72

68 MODULUS operator to splice up a dataset SAS Programming September 11, / 72

69 Another way to do the phone data... SAS Programming September 11, / 72

70 Application of modulus to longitude data The New Zealand data includes longitudinal coordinates on both sides of the international date line, although they are primarily to the the West of it. Some of the longitude values are recorded as negative, so you might have one earthquake with longitude 179 (meaning 179 degrees east of Greenwich) and another with longitude -179 (meaning 179 degrees west of Greenwich), but really there are only two degrees of longitude separating them. On a scatterplot, it would make sense to have them close together. How can we fix this problem? SAS Programming September 11, / 72

71 Application of modulus to longitude data: no modulus This data is for eventtype = earthquake only SAS Programming September 11, / 72

72 Application of modulus to longitude data: with modulus When I first read in the data, I added the line in the datastep longitude = mod(longitude+360,360); This doesn t effect positive longitudes, but allows something with a longitude of -179 to have a longitude of 181, which is where we want it. SAS Programming September 11, / 72

Intro. Scheme Basics. scm> 5 5. scm>

Intro. 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 information

Essentials of PDV: Directing the Aim to Understanding the DATA Step! Arthur Xuejun Li, City of Hope National Medical Center, Duarte, CA

Essentials of PDV: Directing the Aim to Understanding the DATA Step! Arthur Xuejun Li, City of Hope National Medical Center, Duarte, CA PharmaSUG 2013 - Paper TF17 Essentials of PDV: Directing the Aim to Understanding the DATA Step! Arthur Xuejun Li, City of Hope National Medical Center, Duarte, CA ABSTRACT Beginning programmers often

More information

Notes on Simulations in SAS Studio

Notes on Simulations in SAS Studio Notes on Simulations in SAS Studio If you are not careful about simulations in SAS Studio, you can run into problems. In particular, SAS Studio has a limited amount of memory that you can use to write

More information

STA 570 Spring Lecture 5 Tuesday, Feb 1

STA 570 Spring Lecture 5 Tuesday, Feb 1 STA 570 Spring 2011 Lecture 5 Tuesday, Feb 1 Descriptive Statistics Summarizing Univariate Data o Standard Deviation, Empirical Rule, IQR o Boxplots Summarizing Bivariate Data o Contingency Tables o Row

More information

Lecture-14 Lookup Functions

Lecture-14 Lookup Functions Lecture-14 Lookup Functions How do I write a formula to compute tax rates based on income? Given a product ID, how can I look up the product s price? Suppose that a product s price changes over time. I

More information

If Statements, For Loops, Functions

If Statements, For Loops, Functions Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements

More information

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

You ve already read basics of simulation now I will be taking up method of simulation, that is Random Number Generation

You ve already read basics of simulation now I will be taking up method of simulation, that is Random Number Generation Unit 5 SIMULATION THEORY Lesson 39 Learning objective: To learn random number generation. Methods of simulation. Monte Carlo method of simulation You ve already read basics of simulation now I will be

More information

Spectroscopic Analysis: Peak Detector

Spectroscopic Analysis: Peak Detector Electronics and Instrumentation Laboratory Sacramento State Physics Department Spectroscopic Analysis: Peak Detector Purpose: The purpose of this experiment is a common sort of experiment in spectroscopy.

More information

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below. Graphing in Excel featuring Excel 2007 1 A spreadsheet can be a powerful tool for analyzing and graphing data, but it works completely differently from the graphing calculator that you re used to. If you

More information

1 Introduction to Using Excel Spreadsheets

1 Introduction to Using Excel Spreadsheets Survey of Math: Excel Spreadsheet Guide (for Excel 2007) Page 1 of 6 1 Introduction to Using Excel Spreadsheets This section of the guide is based on the file (a faux grade sheet created for messing with)

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

Creating a Box-and-Whisker Graph in Excel: Step One: Step Two:

Creating a Box-and-Whisker Graph in Excel: Step One: Step Two: Creating a Box-and-Whisker Graph in Excel: It s not as simple as selecting Box and Whisker from the Chart Wizard. But if you ve made a few graphs in Excel before, it s not that complicated to convince

More information

Practice Problems for the Final

Practice Problems for the Final ECE-250 Algorithms and Data Structures (Winter 2012) Practice Problems for the Final Disclaimer: Please do keep in mind that this problem set does not reflect the exact topics or the fractions of each

More information

Assignment 0. Nothing here to hand in

Assignment 0. Nothing here to hand in Assignment 0 Nothing here to hand in The questions here have solutions attached. Follow the solutions to see what to do, if you cannot otherwise guess. Though there is nothing here to hand in, it is very

More information

Lecture 1: Overview

Lecture 1: Overview 15-150 Lecture 1: Overview Lecture by Stefan Muller May 21, 2018 Welcome to 15-150! Today s lecture was an overview that showed the highlights of everything you re learning this semester, which also meant

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9 Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9 Contents 1 Introduction to Using Excel Spreadsheets 2 1.1 A Serious Note About Data Security.................................... 2 1.2

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;

More information

SCSUG Paper THE SECRET TO SAS DATES. Alison Little, MPP Texas Health and Human Services Commission

SCSUG Paper THE SECRET TO SAS DATES. Alison Little, MPP Texas Health and Human Services Commission SCSUG Paper THE SECRET TO SAS DATES Alison Little, MPP Texas Health and Human Services Commission ABSTRACT How do you know whether the field you are working with which is called birth date or procedure

More information

Understanding and Applying the Logic of the DOW-Loop

Understanding and Applying the Logic of the DOW-Loop PharmaSUG 2014 Paper BB02 Understanding and Applying the Logic of the DOW-Loop Arthur Li, City of Hope National Medical Center, Duarte, CA ABSTRACT The DOW-loop is not official terminology that one can

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

Principles of Algorithm Design

Principles of Algorithm Design Principles of Algorithm Design When you are trying to design an algorithm or a data structure, it s often hard to see how to accomplish the task. The following techniques can often be useful: 1. Experiment

More information

CSE 501 Midterm Exam: Sketch of Some Plausible Solutions Winter 1997

CSE 501 Midterm Exam: Sketch of Some Plausible Solutions Winter 1997 1) [10 pts] On homework 1, I asked about dead assignment elimination and gave the following sample solution: 8. Give an algorithm for dead assignment elimination that exploits def/use chains to work faster

More information

Interleaving a Dataset with Itself: How and Why

Interleaving a Dataset with Itself: How and Why cc002 Interleaving a Dataset with Itself: How and Why Howard Schreier, U.S. Dept. of Commerce, Washington DC ABSTRACT When two or more SAS datasets are combined by means of a SET statement and an accompanying

More information

Note on homework for SAS date formats

Note on homework for SAS date formats Note on homework for SAS date formats I m getting error messages using the format MMDDYY10D. even though this is listed on websites for SAS date formats. Instead, MMDDYY10 and similar (without the D seems

More information

Effectively Utilizing Loops and Arrays in the DATA Step

Effectively Utilizing Loops and Arrays in the DATA Step Paper 1618-2014 Effectively Utilizing Loops and Arrays in the DATA Step Arthur Li, City of Hope National Medical Center, Duarte, CA ABSTRACT The implicit loop refers to the DATA step repetitively reading

More information

Discussion 11. Streams

Discussion 11. Streams Discussion 11 Streams A stream is an element and a promise to evaluate the rest of the stream. You ve already seen multiple examples of this and its syntax in lecture and in the books, so I will not dwell

More information

9.2 Types of Errors in Hypothesis testing

9.2 Types of Errors in Hypothesis testing 9.2 Types of Errors in Hypothesis testing 1 Mistakes we could make As I mentioned, when we take a sample we won t be 100% sure of something because we do not take a census (we only look at information

More information

From An Introduction to SAS University Edition. Full book available for purchase here.

From An Introduction to SAS University Edition. Full book available for purchase here. From An Introduction to SAS University Edition. Full book available for purchase here. Contents List of Programs... xi About This Book... xvii About the Author... xxi Acknowledgments... xxiii Part 1: Getting

More information

This module presents the star schema, an alternative to 3NF schemas intended for analytical databases.

This module presents the star schema, an alternative to 3NF schemas intended for analytical databases. Topic 3.3: Star Schema Design This module presents the star schema, an alternative to 3NF schemas intended for analytical databases. Star Schema Overview The star schema is a simple database architecture

More information

LOOPS. Repetition using the while statement

LOOPS. Repetition using the while statement 1 LOOPS Loops are an extremely useful feature in any programming language. They allow you to direct the computer to execute certain statements more than once. In Python, there are two kinds of loops: while

More information

10.4 Linear interpolation method Newton s method

10.4 Linear interpolation method Newton s method 10.4 Linear interpolation method The next best thing one can do is the linear interpolation method, also known as the double false position method. This method works similarly to the bisection method by

More information

Divisibility Rules and Their Explanations

Divisibility Rules and Their Explanations Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although

More information

Using pivot tables in Excel (live exercise with data)

Using pivot tables in Excel (live exercise with data) Using pivot tables in Excel (live exercise with data) In chapter four, we used B.C. s political donations data to learn how to build pivot tables, which group elements in your data and summarize the information

More information

Introduction to Geospatial Analysis

Introduction to Geospatial Analysis Introduction to Geospatial Analysis Introduction to Geospatial Analysis 1 Descriptive Statistics Descriptive statistics. 2 What and Why? Descriptive Statistics Quantitative description of data Why? Allow

More information

Using Pivot Tables in Excel (Live Exercise with Data)

Using Pivot Tables in Excel (Live Exercise with Data) Chapter 4 Using Pivot Tables in Excel (Live Exercise with Data) In chapter four, we used B.C. s political donations data to learn how to build pivot tables, which group elements in your data and summarize

More information

Sorting. There exist sorting algorithms which have shown to be more efficient in practice.

Sorting. There exist sorting algorithms which have shown to be more efficient in practice. Sorting Next to storing and retrieving data, sorting of data is one of the more common algorithmic tasks, with many different ways to perform it. Whenever we perform a web search and/or view statistics

More information

Chapter Four: Loops II

Chapter Four: Loops II Chapter Four: Loops II Slides by Evan Gallagher & Nikolay Kirov Chapter Goals To understand nested loops To implement programs that read and process data sets To use a computer for simulations Processing

More information

Congruence Arithmetic

Congruence Arithmetic Module 4 Congruence Arithmetic Popper 4 Introduction to what is like Modulus choices Partitions by modulus Mod 5 Mod 7 Mod 30 Modular Arithmetic Addition Subtraction Multiplication INTEGERS! Mod 12 Cayley

More information

Level I: Getting comfortable with my data in SAS. Descriptive Statistics

Level I: Getting comfortable with my data in SAS. Descriptive Statistics Level I: Getting comfortable with my data in SAS. Descriptive Statistics Quick Review of reading Data into SAS Preparing Data 1. Variable names in the first row make sure they are appropriate for the statistical

More information

MIS 0855 Data Science (Section 006) Fall 2017 In-Class Exercise (Day 15) Creating Interactive Dashboards

MIS 0855 Data Science (Section 006) Fall 2017 In-Class Exercise (Day 15) Creating Interactive Dashboards MIS 0855 Data Science (Section 006) Fall 2017 In-Class Exercise (Day 15) Creating Interactive Dashboards Objective: Create a dashboard with interactive data filtering using Tableau Learning Outcomes: Understand

More information

MIT AITI Python Software Development

MIT AITI Python Software Development MIT AITI Python Software Development PYTHON L02: In this lab we practice all that we have learned on variables (lack of types), naming conventions, numeric types and coercion, strings, booleans, operator

More information

Paper PS05_05 Using SAS to Process Repeated Measures Data Terry Fain, RAND Corporation Cyndie Gareleck, RAND Corporation

Paper PS05_05 Using SAS to Process Repeated Measures Data Terry Fain, RAND Corporation Cyndie Gareleck, RAND Corporation Paper PS05_05 Using SAS to Process Repeated Measures Data Terry Fain, RAND Corporation Cyndie Gareleck, RAND Corporation ABSTRACT Data that contain multiple observations per case are called repeated measures

More information

CS Summer 2013

CS Summer 2013 CS 1110 - Summer 2013 intro to programming -- how to think like a robot :) we use the Python* language (www.python.org) programming environments (many choices): Eclipse (free from www.eclipse.org), or

More information

Chapter 6: DESCRIPTIVE STATISTICS

Chapter 6: DESCRIPTIVE STATISTICS Chapter 6: DESCRIPTIVE STATISTICS Random Sampling Numerical Summaries Stem-n-Leaf plots Histograms, and Box plots Time Sequence Plots Normal Probability Plots Sections 6-1 to 6-5, and 6-7 Random Sampling

More information

APPM 2460 Matlab Basics

APPM 2460 Matlab Basics APPM 2460 Matlab Basics 1 Introduction In this lab we ll get acquainted with the basics of Matlab. This will be review if you ve done any sort of programming before; the goal here is to get everyone on

More information

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Week 02 Module 06 Lecture - 14 Merge Sort: Analysis So, we have seen how to use a divide and conquer strategy, we

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

Program 1: Generating Summation Puzzles

Program 1: Generating Summation Puzzles Program 1: Generating Summation Puzzles Owen Kaser October 3, 2015 Due: 15 October 2015, end of class. 1 Introduction Textbook section 5.3.3 gives pseudocode to solve a given summation puzzle. We want

More information

Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn

Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn Problem Write and test a Scheme program to compute how many days are spanned by two given days. The program will include a procedure

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL We have spent the first part of the course learning Excel: importing files, cleaning, sorting, filtering, pivot tables and exporting

More information

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client Lab 2.0 - MySQL CISC3140, Fall 2011 DUE: Oct. 6th (Part 1 only) Part 1 1. Getting started This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client host

More information

Static verification of program running time

Static verification of program running time Static verification of program running time CIS 673 course project report Caleb Stanford December 2016 Contents 1 Introduction 2 1.1 Total Correctness is Not Enough.................................. 2

More information

n! = 1 * 2 * 3 * 4 * * (n-1) * n

n! = 1 * 2 * 3 * 4 * * (n-1) * n The Beauty and Joy of Computing 1 Lab Exercise 9: Problem self-similarity and recursion Objectives By completing this lab exercise, you should learn to Recognize simple self-similar problems which are

More information

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017 SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

RouteOp. Step 1: Make sure requirements are met.

RouteOp. Step 1: Make sure requirements are met. RouteOp If you are just getting started please note that the features are not enabled until your first call. You will receive a welcome email to get the ball rolling and will be hearing from your implementation

More information

CS264: Homework #1. Due by midnight on Thursday, January 19, 2017

CS264: Homework #1. Due by midnight on Thursday, January 19, 2017 CS264: Homework #1 Due by midnight on Thursday, January 19, 2017 Instructions: (1) Form a group of 1-3 students. You should turn in only one write-up for your entire group. See the course site for submission

More information

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL We have spent the first part of the course learning Excel: importing files, cleaning, sorting, filtering, pivot tables and exporting

More information

Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA

Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA Paper DM09 Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA ABSTRACT In this electronic age we live in, we usually receive the detailed specifications from our biostatistician

More information

Table of Contents. The RETAIN Statement. The LAG and DIF Functions. FIRST. and LAST. Temporary Variables. List of Programs.

Table of Contents. The RETAIN Statement. The LAG and DIF Functions. FIRST. and LAST. Temporary Variables. List of Programs. Table of Contents List of Programs Preface Acknowledgments ix xvii xix The RETAIN Statement Introduction 1 Demonstrating a DATA Step with and without a RETAIN Statement 1 Generating Sequential SUBJECT

More information

Table of Contents. 1. Cover Page 2. Quote 3. Calculated Fields 4. Show Values As 5. Multiple Data Values 6. Enroll Today!

Table of Contents. 1. Cover Page 2. Quote 3. Calculated Fields 4. Show Values As 5. Multiple Data Values 6. Enroll Today! Table of Contents 1. Cover Page 2. Quote 3. Calculated Fields 4. Show Values As 5. Multiple Data Values 6. Enroll Today! "It is Kind Of fun to do the IMPOSSIBLE" Walt Disney Calculated Fields The purpose

More information

Intellicus Enterprise Reporting and BI Platform

Intellicus Enterprise Reporting and BI Platform Designing Adhoc Reports Intellicus Enterprise Reporting and BI Platform Intellicus Technologies info@intellicus.com www.intellicus.com Designing Adhoc Reports i Copyright 2012 Intellicus Technologies This

More information

Chameleon Metadata s Data Science Basics Tutorial Series. DSB-2: Information Gain (IG) By Eric Thornton,

Chameleon Metadata s Data Science Basics Tutorial Series. DSB-2: Information Gain (IG) By Eric Thornton, Chameleon Metadata s Data Science Basics Tutorial Series Data Science Basics Syllabus for DSB-2 (DSB-2-Infographic-1) Download PDF version here: DSB-2-Information-Gain-V10.pdf DSB-2: Information Gain (IG)

More information

CS450 - Structure of Higher Level Languages

CS450 - Structure of Higher Level Languages Spring 2018 Streams February 24, 2018 Introduction Streams are abstract sequences. They are potentially infinite we will see that their most interesting and powerful uses come in handling infinite sequences.

More information

Algorithm Design and Recursion. Search and Sort Algorithms

Algorithm Design and Recursion. Search and Sort Algorithms Algorithm Design and Recursion Search and Sort Algorithms Objectives To understand the basic techniques for analyzing the efficiency of algorithms. To know what searching is and understand the algorithms

More information

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

More information

Data Explorer: User Guide 1. Data Explorer User Guide

Data Explorer: User Guide 1. Data Explorer User Guide Data Explorer: User Guide 1 Data Explorer User Guide Data Explorer: User Guide 2 Contents About this User Guide.. 4 System Requirements. 4 Browser Requirements... 4 Important Terminology.. 5 Getting Started

More information

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information

MAT 090 Brian Killough s Instructor Notes Strayer University

MAT 090 Brian Killough s Instructor Notes Strayer University MAT 090 Brian Killough s Instructor Notes Strayer University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Motivation. Prerequisites. - You have installed Tableau Desktop on your computer.

Motivation. Prerequisites. - You have installed Tableau Desktop on your computer. Prerequisites - You have installed Tableau Desktop on your computer. Available here: http://www.tableau.com/academic/students - You have downloaded the data. Available here: https://data.nasa.gov/view/angv-aquq

More information

Chapter 2: Descriptive Statistics (Part 1)

Chapter 2: Descriptive Statistics (Part 1) Frequency 0 2 4 6 8 12 Chapter 2: Descriptive Statistics (Part 1) 2.1: Frequency Distributions and their Graphs Definition A frequency distribution is something (usually a table) that shows what values

More information

2. The histogram. class limits class boundaries frequency cumulative frequency

2. The histogram. class limits class boundaries frequency cumulative frequency MA 115 Lecture 03 - Some Standard Graphs Friday, September, 017 Objectives: Introduce some standard statistical graph types. 1. Some Standard Kinds of Graphs Last week, we looked at the Frequency Distribution

More information

Statistics 13, Lab 1. Getting Started. The Mac. Launching RStudio and loading data

Statistics 13, Lab 1. Getting Started. The Mac. Launching RStudio and loading data Statistics 13, Lab 1 Getting Started This first lab session is nothing more than an introduction: We will help you navigate the Statistics Department s (all Mac) computing facility and we will get you

More information

LESSON 3 CONTROL STRUCTURES

LESSON 3 CONTROL STRUCTURES LESSON CONTROL STRUCTURES PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Logic, Logical Operators, AND Relational Operators..... - Logical AND (&&) Truth

More information

BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA

BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA Learning objectives: Getting data ready for analysis: 1) Learn several methods of exploring the

More information

One-PROC-Away: The Essence of an Analysis Database Russell W. Helms, Ph.D. Rho, Inc.

One-PROC-Away: The Essence of an Analysis Database Russell W. Helms, Ph.D. Rho, Inc. One-PROC-Away: The Essence of an Analysis Database Russell W. Helms, Ph.D. Rho, Inc. Chapel Hill, NC RHelms@RhoWorld.com www.rhoworld.com Presented to ASA/JSM: San Francisco, August 2003 One-PROC-Away

More information

Introduction. Syllabus

Introduction. Syllabus Introduction Syllabus Lecturer: James Degnan Office: SMLC 342 Office Hours: M 12:30-1:30, W 1:30-2:30 E-mail: jamdeg@unm.edu Textbook: Learning SAS by example, by Ron Cody, http://unm.worldcat.org/title/learning-sas-by-example-a-programmersguide/oclc/174000956&referer=brief

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

Things you ll know (or know better to watch out for!) when you leave in December: 1. What you can and cannot infer from graphs.

Things you ll know (or know better to watch out for!) when you leave in December: 1. What you can and cannot infer from graphs. 1 2 Things you ll know (or know better to watch out for!) when you leave in December: 1. What you can and cannot infer from graphs. 2. How to construct (in your head!) and interpret confidence intervals.

More information

More About WHILE Loops

More About WHILE Loops More About WHILE Loops http://people.sc.fsu.edu/ jburkardt/isc/week04 lecture 07.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt Department of Scientific

More information

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays A Beginner s Guide to Programming Logic, Introductory Chapter 6 Arrays Objectives In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested

More information

CH 21 CONSECUTIVE INTEGERS

CH 21 CONSECUTIVE INTEGERS 201 CH 21 CONSECUTIVE INTEGERS Introduction An integer is either a positive whole number, or zero, or a negative whole number; in other words it s the collection of numbers:... 4, 3, 2, 1, 0, 1, 2, 3,

More information

Getting Started with Arrays and DO LOOPS. Created 01/2004, Updated 03/2008, Afton Royal Training & Consulting

Getting Started with Arrays and DO LOOPS. Created 01/2004, Updated 03/2008, Afton Royal Training & Consulting Getting Started with Arrays and DO LOOPS Created 01/2004, Updated 03/2008, Afton Royal Training & Consulting What to Expect We have 30 minutes to learn how to use DO LOOPS and arrays. We will assume you

More information

Excel Basics: Working with Spreadsheets

Excel Basics: Working with Spreadsheets Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.

More information

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise If you re not already crazy about Scheme (and I m sure you are), then here s something to get

More information

Chapter 2 The SAS Environment

Chapter 2 The SAS Environment Chapter 2 The SAS Environment Abstract In this chapter, we begin to become familiar with the basic SAS working environment. We introduce the basic 3-screen layout, how to navigate the SAS Explorer window,

More information

HOUR 4 Understanding Events

HOUR 4 Understanding Events HOUR 4 Understanding Events It s fairly easy to produce an attractive interface for an application using Visual Basic.NET s integrated design tools. You can create beautiful forms that have buttons to

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started

CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started Handout written by Julie Zelenski, Mehran Sahami, Robert Plummer, and Jerry Cain. After today s lecture, you should run home and read

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

Frequency Distributions

Frequency Distributions Displaying Data Frequency Distributions After collecting data, the first task for a researcher is to organize and summarize the data so that it is possible to get a general overview of the results. Remember,

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions

More information

Using Microsoft Excel

Using Microsoft Excel Using Microsoft Excel Introduction This handout briefly outlines most of the basic uses and functions of Excel that we will be using in this course. Although Excel may be used for performing statistical

More information

CS61A Summer 2010 George Wang, Jonathan Kotker, Seshadri Mahalingam, Eric Tzeng, Steven Tang

CS61A Summer 2010 George Wang, Jonathan Kotker, Seshadri Mahalingam, Eric Tzeng, Steven Tang CS61A Notes Week 6B: Streams Streaming Along A stream is an element and a promise to evaluate the rest of the stream. You ve already seen multiple examples of this and its syntax in lecture and in the

More information

A Basic Guide to Using Matlab in Econ 201FS

A Basic Guide to Using Matlab in Econ 201FS A Basic Guide to Using Matlab in Econ 201FS Matthew Rognlie February 1, 2010 Contents 1 Finding Matlab 2 2 Getting Started 2 3 Basic Data Manipulation 3 4 Plotting and Finding Returns 4 4.1 Basic Price

More information

CS1 Lecture 5 Jan. 25, 2019

CS1 Lecture 5 Jan. 25, 2019 CS1 Lecture 5 Jan. 25, 2019 HW1 due Monday, 9:00am. Notes: Do not write all the code at once before starting to test. Take tiny steps. Write a few lines test... add a line or two test... add another line

More information

CS1132 Fall 2009 Assignment 1. 1 The Monty Hall Dillemma. 1.1 Programming the game

CS1132 Fall 2009 Assignment 1. 1 The Monty Hall Dillemma. 1.1 Programming the game CS1132 Fall 2009 Assignment 1 Adhere to the Code of Academic Integrity. You may discuss background issues and general solution strategies with others and seek help from course staff, but the homework you

More information