BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

 

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?

2 REPLIES 2
LinusH
Tourmaline | Level 20

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).

Data never sleeps
Kurt_Bremser
Super User

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 808 views
  • 0 likes
  • 3 in conversation