BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

 

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;

5 REPLIES 5
PaigeMiller
Diamond | Level 26

You can run the code and see what it does.

--
Paige Miller
JosvanderVelden
SAS Super FREQ
I doubt the code you posted has ever worked. There are too many syntax errors. Please contact the person who wrote the code and ask him/her/they to explain. If that is not an option and you have the cca dataset you can run the code and try to correct the errors and then you should be able to draw conclusions.
Tom
Super User Tom
Super User

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;

 

HeatherNewton
Quartz | Level 8

What about lines above the condition; do they get run regardless of the condition?

Tom
Super User Tom
Super User

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 775 views
  • 0 likes
  • 4 in conversation