The following PROC SQL
step creates the view Sasuser.Raisev, which includes the columns Salary
and MonthlySalary. A subsequent query that references the view shows
the columns.
proc sql;
create view sasuser.raisev as
select empid, jobcode,
salary format=dollar12.,
salary/12 as MonthlySalary
format=dollar12.
from payrollmaster;
proc sql;
select *
from sasuser.raisev
where jobcode in ('PT2','PT3'),
|
|
Suppose you want to
update the view to show a salary increase for employees whose job
code is PT3
. You can use an UPDATE
statement to change the column Salary and a WHERE clause in the UPDATE
clause to identify the rows where the value of JobCode equals PT3
.
Though MonthlySalary is a derived column and cannot be changed using
an UPDATE statement, it is updated because it is derived from Salary.
When the PROC SQL step
is submitted, a note appears in the SAS log that indicates how many
rows were updated:
proc sql;
update sasuser.raisev
set salary=salary * 1.20
where jobcode='PT3';
Table 7.3 SAS Log
116 proc sql;
117 update sasuser.raisev
118 set salary=salary * 1.20
119 where jobcode='PT3';
NOTE: 2 rows were updated in SASUSER.RAISEV.
|
Note: Remember that the rows were
updated in the table that underlies the view Sasuser.Raisev.
When you resubmit the
query, the updated values for Salary and MonthlySalary appear in the
rows where JobCode equals PT3
:
proc sql;
select *
from sasuser.raisev
where jobcode in ('PT2','PT3'),
|
|