BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5

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

6 REPLIES 6
Anotherdream
Quartz | Level 8

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

Haikuo
Onyx | Level 15

Exactly, have you tried it:

if 90<=DPD<=720;

Haikuo

Reeza
Super User

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

Anotherdream
Quartz | Level 8

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

Haikuo
Onyx | Level 15

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

Haikuo

Haikuo
Onyx | Level 15

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 682 views
  • 0 likes
  • 4 in conversation