| Creating Variables |
| Executing Multiple Statements
Conditionally |
During the first iteration of the DATA step, the first
observation is read from Finance.Records. The variables
Amount and Rate are dropped. |
data finance.newloan;
set finance.records(drop=amount rate);
length Type $ 14;
TotalLoan+payment;
if code='1' then
do;
if months=360 then
type='Fixed Mortgage';
else type='Fixed Other';
end;
else type='Variable';
run;
|
| Account | Amount | Rate | Months | Payment | Code |
| 101-1092 | 22000 | 0.1000 | 60 | 467.43 | 1 |
| 101-1731 | 114000 | 0.0950 | 360 | 958.57 | 2 |
| 101-1289 | 10000 | 0.1050 | 36 | 325.02 | 2 |
| 101-3144 | 3500 | 0.1050 | 12 | 308.52 | 1 |
| The LENGTH statement is a compile-time statement and is therefore not executed. (Remember to change LENGTH statements to accommodate new variable values such as Fixed Mortgage.) |
data finance.newloan;
set finance.records(drop=amount rate);
length Type $ 14;
TotalLoan+payment;
if code='1' then
do;
if months=360 then
type='Fixed Mortgage';
else type='Fixed Other';
end;
else type='Variable';
run;
Next, the value of |
data finance.newloan;
set finance.records(drop=amount rate);
length Type $ 14;
TotalLoan+payment;
if code='1' then
do;
if months=360 then
type='Fixed Mortgage';
else type='Fixed Other';
end;
else type='Variable';
run;
|
| Account | Amount | Rate | Months | Payment | Code |
| 101-1092 | 22000 | 0.1000 | 60 | 467.43 | 1 |
| 101-1731 | 114000 | 0.0950 | 360 | 958.57 | 2 |
| 101-1289 | 10000 | 0.1050 | 36 | 325.02 | 2 |
| 101-3144 | 3500 | 0.1050 | 12 | 308.52 | 1 |
![]() ![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.