| Creating Variables |
| Executing Multiple Statements
Conditionally |
| Nesting DO Groups
Because DO and END statements are executable SAS statements, you can nest a DO group within another DO group.
if code='1' then
do;
if months=360 then
do;
Type='Fixed Mortgage';
note='Check against current
prime lending Rate.';
end;
else Type='Fixed Other';
end;
else Type='Variable';
In this case, if the value of if code='1' then
do;
if months=360 then
do;
Type='Fixed Mortgage';
note='Check against current
prime lending Rate.';
end;
else Type='Fixed Other';
end;
else Type='Variable';
The first statement in the DO group determines if the value of
if code='1' then
do;
if months=360 then
do;
Type='Fixed Mortgage';
note='Check against current
prime lending Rate.';
end;
else Type='Fixed Other';
end;
else Type='Variable';
Every DO statement must have a corresponding END statement. When nesting DO groups, be careful to match each DO statement with an END statement. Indenting statements helps you keep track of DO groups.
if code='1' then
do;
| if months=360 then
| do;
| | Type='Fixed Mortgage';
| | note='Check against current
| | prime lending Rate.';
| end;
| else Type='Fixed Other';
end;
else Type='Variable';
When an IF statement is true, its corresponding ELSE statement is ignored.
if code='1' then
| do;
| if months=360 then
| | do;
| | Type='Fixed Mortgage';
| | note='Check against current
| | prime lending Rate.';
| | end;
| else Type='Fixed Other';
| end;
else Type='Variable';
|
![]() ![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.