if block_code_1 ne '' and date_block_code_1> "&SAMPDATE"d then block_code_1=''; if block_code_2 ne '' and date_block_code_2> "&SAMPDATE"d then block_code_2=''; if DATE_CARD_OPENED <= "&SAMPDATE"D; if HKBCBS_RL_STATUS='' then HKBCBS_RL_STATUS='0'; if block_code_1='A' and date_block_code_1<="&SAMPDATE"d then do; ind_default=1; bad_status='CHARGEOFF'; *date_default=coalesce(date_block_code_1, date_block_code_2); date_default=date_block_code_1; end;
In the above piece of code, what I dont get is the third line
if DATE_CARD_OPENED <= "&SAMPDATE"D;
an if statement without then, what does it mean? does it mean the next if then statement on the fourth line only come true when it fulfil the third if statement?
IF statements, with no THEN following, cause the statement to include or exclude observations from the data set.
if DATE_CARD_OPENED <= "&SAMPDATE"D;
includes observations where DATE_CARD_OPENED is less than or equal to that date in &SAMPDATE, and excludes observations where DATE_CARD_OPENED is greater than &SAMPDATE
It's usually called a subsetting if.
It means that the following lines of code isn't executed for observations that doesn't meet the criteria, including any potential implicit OUTPUT at the end of the data step.
no it's subsetting. you may read about it in the documentation. https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.