Help using Base SAS procedures

Another way to reflect "Between" in dataset?

Reply
Contributor
Posts: 59

Another way to reflect "Between" in dataset?

data DSM2;

  set DSM1;

  Orig = &pbd_date-LN_FST_DUE_DT;

  DPD = &pbd_date-LN_NXT_PMT_DUE_DT;

  if DPD >=90 and DPD <=720;

  if Orig >365;

  run;

notice the

if DPD >=90 and DPD <=720;

I believe there is another way to reflect in between?  Something like  90<=DPD<=720

Super Contributor
Posts: 418

Re: Another way to reflect "Between" in dataset?

Posted in reply to omega1983

proc sql;

create table DSM2 as

select  &pbd_date-LN_FST_DUE_DT as Orig

,&pbd_date-LN_NXT_PMT_DUE_DT as DPD

from DSM1

where (&pbd_date-LN_NXT_PMT_DUE_DT) between 90 and 720 AND

(&pbd_date-LN_FST_DUE_DT) > 365;

quit;

run;

There ya go

Respected Advisor
Posts: 3,156

Re: Another way to reflect "Between" in dataset?

Posted in reply to omega1983

Exactly, have you tried it:

if 90<=DPD<=720;

Haikuo

Super User
Posts: 19,805

Re: Another way to reflect "Between" in dataset?

Except that won't work in macro code in certain circumstances, so be careful where you use it.

Super Contributor
Posts: 418

Re: Another way to reflect "Between" in dataset?

I actually had this exact issue Reeze, and that is why I moved to running the proc sql version that I originally suggested. I have not run into the proc sql having any issues in any of the macro coding that I have used thus far.


IF anyone thinks it would cause problems please say so!

Brandon

Respected Advisor
Posts: 3,156

Re: Another way to reflect "Between" in dataset?

Thanks, Fareeza, good to know. It would be helpful if someone could elaborate more  details on the errors when using this in Macro.

Haikuo

Respected Advisor
Posts: 3,156

Re: Another way to reflect "Between" in dataset?

FWIW, Finally I bumped into something from SAS-L regarding this matter:

Quote from one of Lassen's recent posts:

"

as the macro language interpreter evaluates it like this

1<0<2 -> (1<0)<2 -> 0<2 -> 1

"

Which means macro language evaluates expressions in a segmental pattern, not as a whole. It is not necessarily causing error message, it just interprets it differently, therefore leads to unexpected results. So as long as you know know how exactly it works, you can still use it in Macro language.

Haikuo

Ask a Question
Discussion stats
  • 6 replies
  • 168 views
  • 0 likes
  • 4 in conversation