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;
Let's ignore the unmatched quotes and just look at the SUBSETTING IF statement you asked about.
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;
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.