Lecture 6 Modifying and combining SAS Data Sets

Lecture 6 Modifying and combining SAS Data Sets - I OWA S...

Info iconThis preview shows pages 1–7. 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 DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: I OWA S TATE U NIVERSITY Department of Animal Science I OWA S TATE U NIVERSITY Department of Animal Science Modifying and Combing SAS Data Sets (Chapter in the 6 Little SAS Book) Animal Science 500 Lecture No. 6 September 16, 2010 I OWA S TATE U NIVERSITY Department of Animal Science Modifying Variable Lengths The code below uses only 3 character spaces for the county by specifying the length of the location variable You can also use this with numeric variables data new; length location $ 3 ; input location $ 1- 15 date $ rainfall; Cards; /*remember you could use the datalines statement to do the same thing);*/ Story county 6/10/10 4.5 Polk county 6/10/10 6.5 Story county 7/10/10 4.9 Polk county 7/10/10 2.4 ; Run; Quit; I OWA S TATE U NIVERSITY Department of Animal Science Creating new variables You can create variables in the initial data step where you are inputting the data or you can use a new data step to create the variables. As we did when we created 1. Adjusted backfat variables for barrows and gilts 2. Total weight gain during the test period 3. Average daily gain during the test period You do not have to make calculations when making new variables. You could divide backfat, loin muscle are, gain, etc into categories to evaluate if model I OWA S TATE U NIVERSITY Department of Animal Science Creating new variables If you choose to create a new data step you will need to either create a new file in SAS or modify the existing file. Example what we have done in Lab by the following statements Data Pig13 Set Pig12; Alternatively you could create a new file in SAS If you create a new file you may need to merge it with the original data file; This is a place where students often have difficulty I OWA S TATE U NIVERSITY Department of Animal Science Creating New Variables in SAS Both of these options will result in a data set named New with all the variables that have been defined This option creates the variables lograinfall and sqrtrainfall in the initial data step In the second set of code you are creating a new file in SAS and naming it New the set statement tells SAS to Assign the data from the first New to this file New data new; input @ 1 location $ 1- 15 date mmddyy8. rainfall; log_rain = log(rainfall); sqrt_rain= sqrt(rain); datalines; Story county 6/10/10 4.5 Polk county 6/10/10 6.5 Story county 7/10/10 4.9 Polk county 7/10/10 2.4 ; run ; data new; set new; log_rain = log(rainfall); sqrt_rain = sqrt(rain); run ; I OWA S TATE U NIVERSITY Department of Animal Science Creating New Variables in SAS SAS has many other functions to perform various calculations for...
View Full Document

Page1 / 26

Lecture 6 Modifying and combining SAS Data Sets - I OWA S...

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

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