DATA Step, Macro, Functions and more

INTNX Issues

Reply
Occasional Contributor
Posts: 6

INTNX Issues

Hi everyone...

I have a SQL routine that pulls data from a large data warehouse. In it I have a where statement where one of the conditions is as follows:

Where AdmitDT>INTNX('Day', Today(), -181)

Basically, I want to count back and include those records where the AdmitDt is greater than 181 days prior to today. However, SAS does not like this statement at all. I have a feeling that I am doing something that completely demonstrates my lack of knowledge in handling dates and times in SAS. Any help would be appreciated.
Occasional Contributor P_J
Occasional Contributor
Posts: 10

Re: INTNX Issues

Your statement works perfect to me bother data step and proc sql.

97 data test;
98 format AdmitDT yymmddn8.;
99 do i = 1 to 365;
100 AdmitDT = today() - i;
101 output;
102 end;
103 run;

NOTE: The data set WORK.TEST has 365 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


104
105 data t;
106 set test;
107 if AdmitDT > INTNX('Day', Today(), -181);
108 run;

NOTE: There were 365 observations read from the data set WORK.TEST.
NOTE: The data set WORK.T has 180 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


109
110 proc sql;
111 create table t1 as
112 select * from test
113 where AdmitDT > INTNX('Day', Today(), -181);
NOTE: Table WORK.T1 created, with 180 rows and 2 columns.

114 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
Super Contributor
Posts: 359

Re: INTNX Issues

Are you running this in SAS or as a pass-thru. This is a SAS function which will not work if you run in a pass-Thru
Valued Guide
Posts: 2,175

Re: INTNX Issues

to generate code filtering just the last 180 days, let the macro language help .... [pre] Where AdmitDT > "%sysfunc( INTNX( Day, '&sysdate9'd, -181),date9)"d [/pre]

PeterC
Valued Guide
Posts: 632

Re: INTNX Issues

Are there conditions where we cannot replace the INTCK with just
today()-181 ?
Ask a Question
Discussion stats
  • 4 replies
  • 156 views
  • 0 likes
  • 5 in conversation