Creating New Variables

advertisement

While it is far easier to create a new variable in Excel and then import the data set with the old and new variables into SAS, it is also possible to create in SAS new variables which are functions of existing ones.

!. After importing the data from Excel, Click on the Query Builder label.

2. Click on the Computed Columns in the top left.

3. On the resulting screen, drag every variable from the left side to the right. Below I have dragged

Observation from the left list to the right. The other two also need to be moved.

4. The screen should now have all variables on the right and left. Click on the Computed Columns button in the top left.

5. Click New on this screen

6. There are now 6 steps to complete. On step 1, click Advanced expression and then Next

7. In Step 2, first choose the function by clicking on the plus sign next to Functions in the bottom left list.

This will cause a list of functions to appear. Double click on the Log10 function. (This is the logarithm base 10 function)

8. The result should look like this.

9. Close the list of functions by clicking the Negative symbol next to the Functions folder and then click on the plus symbol next to the data set name (Parachute in this example) for a list of variables.

10. Type the variable name inside the parentheses. In this case I chose to take the logarithm of

Tensile_Strength. If you double click the variable name, a prefix of "t1 " will also appear within the parenthesis and will have to be removed). Then click Next

11. In Step 3, rename the Column. SAS names may be of any length but can only contain letters, numbers and the underlining symbol "_". The names cannot start with a number. I named my new variable Log10TS. Click Finish.

12. Close the Dialog box in part 5 above and then click the Run button on the screen below

13. The resulting data set will appear with the additional created column.

Download