- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data def_case; set cca; default=0; bad_status=''; if block_code_1 ne '' and date_block_code_1>"&samoedate"d then block_code="; if date_card_opened<="&sampedate"D; if block_code_1='A' and date_block_code_1<="&SAMPDATE"d then do; ind_default=1; bad_status='CHARGEOFF'; end; ELSE IF refinance_acct ne "" and refINANCE_dATE<="&sampDATE"D THEN DO; ind_default=1; bad_status='REFINANCE_OLD"; end; if product_code in ('CC") ad sme=0 and refion ne 'MAC" and inf_default=1 then output; keep account_no relationship_no IND_CENTRAL_LIMIT ; run;
in the above, does it mean the following:
the line 'if DATE_CARD_OPENED <="&SAMPDATE"D' is a selection if i.e. only rows from cca satisfying this condition would have transformation above or below this condition applied to them;
and then after all transforation is done
at the end we only output to data set def_case_CO_RE when a row satisfied the condition
'if product_code in ("CC") and sme=0 and region ne 'MAC" and ind_default=1;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can run the code and see what it does.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Let's ignore the unmatched quotes and just look at the SUBSETTING IF statement you asked about.
if date_card_opened<="&sampedate"D;
If the condition is TRUE then this iteration of the data step continues and the following commands are evaluated. At the end of the data step iteration an observation is written (when there is no explicit OUTPUT statement in the data step).
If the condition is FALSE then the iteration stops immediate and starts another iteration without executing the implied output. Since the first statement is the SET statement another observation is read in.
You could think of a statement like:
if (condition) ;
As doing the same thing as
if not (condition) then delete;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What about lines above the condition; do they get run regardless of the condition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes. The "executable" statements in a data step are executed in the order they appear.
Non-executable statements are things like LABEL, LENGTH, FORMAT, ARRAY etc that just setup the structure of the data step but do not need to perform any action while the data step is running.