if product_code in ('CC', 'IL', 'RL', 'VI') and sme=0
and region ne 'MAC'
and org_code notin ('801', '802', '751')
and ((block_code_1 not in ('A', 'B', 'D', 'W', 'O', 'J', 'Q', 'I')
and block_code_2 not in ('A', 'B', 'D', 'W','O','J','Q','I'))
or ((block_code_1 in ('A','B','D','W','O','J','Q','I')
or block_code_2 in ('A','B','D','W','O','J','Q','I'))
and current_bal >0 and (block_code_1 ne 'A'
and block_code_2 ne 'A'))) then
output; keep account_no region product_code currency cyrrent_delq ind_default block_code_1 date_block_code_1 block_code_2 date_block_code_1 current_bal org_code logo customer_no account_level_rating; run;
Hi I have the above command, what I am not sure is whether the command of keeping certain columns only happen when the if statement is fulfilled? also what does 'output' means here? only keeping the mentioned columns?
Yes, the KEEP statement comes in effect when writing to the output table.
OUTPUT will tell the data step to output the data with current values set. You can have multiple OUTPUT statements in a data step.
If omitted, an implicit OUTPUT statment is "enforced" (at the end of the data step).
KEEP is a declarative statement; it is evaluated by the data step compiler when the data step is built from your code, so it cannot be executed conditionally (it is in fact never executed).
OUTPUT, OTOH, is an executable statement which can be used conditionally (as is the fact in your code). It writes an observation to the output dataset.
If no OUTPUT is coded by you, the data step compiler will insert one on its own at the very end of the data step, so for every completed data step iteration an observation is written.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.