Download presentation
Presentation is loading. Please wait.
1
A new keyword -- calculated
2
Recall the original 10% bonus query
proc sql; select Employee_ID, Salary, Salary * .10 as Bonus from orion.Employee_Payroll ; quit;
3
Create a report that includes only those employees who receive bonuses less than $3000.
proc sql; select Employee_ID, Employee_Gender, Salary, Salary * .10 as Bonus from orion.Employee_Payroll where Bonus < 3000 ; quit; s102d14
4
Subsetting with Calculated Values
Because a WHERE clause is evaluated before the SELECT clause, columns used in the WHERE clause must exist in the table or be derived from existing columns. Bonus column is not in the source table, an error was generated.
5
Subsetting with Calculated Values--one solution, repeat the calculation.
proc sql; select Employee_ID, Employee_Gender, Salary, Salary * .10 as Bonus from orion.Employee_Payroll where Salary * .10 < 3000 ; quit; s102d14
6
Subsetting with Calculated Values, alternative method – the CALCULATED keyword.
proc sql; select Employee_ID, Employee_Gender, Salary, Salary * .10 as Bonus from orion.Employee_Payroll where calculated Bonus < 3000 ; quit; s102d14
7
Subsetting with Calculated Values – using the CALCULATED keyword in other locations.
proc sql; select Employee_ID, Employee_Gender, Salary, Salary * .10 as Bonus, calculated Bonus/2 as Half from orion.Employee_Payroll where calculated Bonus < 3000 ; quit; s102d14
8
Example--Find all participants at the first examination with average systolic blood press ≥ 250 mmHg
proc sql; describe table dictionary.columns ; quit;
9
Find the variable names
proc sql; select name from dictionary.columns where memname="FRAM30" and upcase(label) contains "SYS" ; quit;
10
Complete the query proc sql; select id, mean(spa1,spf1,sps1) as mnsbp
from fram.fram30 where calculated mnsbp ge 250 ; quit;
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.