STP452topic1

STP452topic1 - STAT 512 Applied Regression Analysis Topic 1...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: STAT 512: Applied Regression Analysis Topic 1 Spring 2008 SAS Introduction Getting help with SAS • SAS Help Documentation: In SAS environment, select menu Help->Getting Started with SAS Software • Applied Statistics and the SAS Programming Language (5th edition) by Cody and Smith. • Google (with appropriately constructed queries) • Statistical Consulting Service: Math G175, 10am-4pm, M-F. http://www.stat.purdue.edu/scs/ • Evening Help Sessions • O ce Hour Example (Price Analysis for Diamond Rings in Singapore) Variables • predictor variable X : weight of diamond in carats; • response variable Y : price in Singapore dollars; Goals • create a scatterplot of the data • t a regression line • predict the price of a sale for a 0.43 carat diamond ring 1 SAS Data Setup /* File: diamond.sas */ *Read in the data using the cards statement. The @@ allows more than one case per line. The lone . represents a missing value and we can use this for prediction of price at that weight; data diamonds; input weight price @@; cards; .17 355 .16 328 .17 350 .18 325 .25 642 .16 342 .15 322 .19 485 .21 483 .15 323 .18 462 .28 823 .16 336 .20 498 .23 595 .29 860 .12 223 .26 663 .25 750 .27 720 .18 468 .16 345 .17 352 .16 332 .17 353 .18 438 .17 318 .18 419 .17 346 .15 315 .17 350 .32 918 .32 919 .15 298 .16 339 .16 338 .23 595 .23 553 .17 345 .33 945 .25 655 .35 1086 .18 443 .25 678 .25 675 .15 287 .26 693 .15 316 .43 . ; *Create new data set that does not include the last case (we do this for plotting purposes since we don't want 0.43 included on the x-axis in our plots); data diamonds1; set diamonds; if price ne .; Syntax Notes: • Each line must end with a semi-colon. • The parts insdie /* ... */ or * ... ; are comments. • There is no output from this statement, but information does appear in the log window. • You can obtain data from an existing SAS le or import data from another le such as a csv le. SAS proc print If we want to print the data we can apply the print procecure in SAS as follows: /* File: diamond.sas */ proc print data=diamonds; run; and the output looks like: 2 Obs weight price 1 0.17 355 2 0.16 328 3 0.17 350 ... 47 0.26 693 48 0.15 316 49 0.43 . SAS proc gplot We want to plot the data as a scatterplot, using circles to represent data points and adding a smoothing curve to see if it looks linear. The symbol statement v=circle (v stands for value ) lets us do this. The symbol statement i=sm70 will add a smooth line using splines (interpolation=smooth). These are options which stay on until you turn them o . In order for the smoothing to work properly we need to sort the data by the X variable. /* File: diamond.sas */ *Sort the data according to weight (if we don't, the smoothing curve on our plot will not work correctly); proc sort data=diamonds1; by weight; *Generate a scatterplot with smooth curve fitted to the data. Note that there are several preceding statements that can be used to title the plot and axes.; symbol1 v=circle i=sm70;...
View Full Document

{[ snackBarMessage ]}

Page1 / 26

STP452topic1 - STAT 512 Applied Regression Analysis Topic 1...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online