[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: HOWTO find last Friday of month?
From: Ian Whitlock <WHITLOI1 () WESTAT ! COM>
Date: 2002-10-31 18:26:01
[Download RAW message or body]
Rob,
No, you have it, but it is the one you never look at, just above the
language reference dictionary.
After looking at it, I first thought you could do the same thing with
months. You cannot. They gave an example "MONTH2.2" so I tried "MONTH1.3",
no good. Ah-ha, new system. So I tried
905 data _null_ ;
906 dt = "1nov2002"d ;
907 y = intnx ("month.3" , dt , 0 ) ;
908 x1 = intnx ( "month3.1" , dt, 0 ) ;
909 x2 = intnx ( "month3.2" , dt, 0 ) ;
910 x3 = intnx ( "month3.3" , dt, 0 ) ;
911 format _all_ date9. ;
912 run ;
NOTE: Invalid argument to function INTNX at line 907 column 8.
dt=01NOV2002 y=. x1=01OCT2002 x2=01NOV2002 x3=01SEP2002 _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following
places. The results of the
operations have been set to missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 907:8
NOTE: DATA statement used:
real time 0.04 seconds
Can anyone explain in English what this means? (I am not interested in the
mistake [I broke the rules to indicate the month rules are different from
the week rules and to get some output cheaply]. It is the "good" values
that I want to understand.) At first I thought "MONTHm.n" might mean the
nth month of a sequence of m months beginning some time. X1 and X2 appear
to be consistent with this theory.
Here if my final attempt at understanding before asking for help.
1071 data _null_ ;
1072 dt = "1jan2002"d ;
1073 do until ( dt > "1dec2002"d ) ;
1074 x1 = intnx ( "month5.1" , dt, 0 ) ;
1075 z1 = intnx ( "month5.1" , dt, 1 ) ;
1076 x2 = intnx ( "month5.2" , dt, 0 ) ;
1077 x3 = intnx ( "month5.3" , dt, 0 ) ;
1078 x4 = intnx ( "month5.4" , dt, 0 ) ;
1079 x5 = intnx ( "month5.5" , dt, 0 ) ;
1080 y1 = intnx ( "month3.1" , dt, 0 ) ;
1081 z2 = intnx ( "month3.1" , dt, 0 ) ;
1082 y2 = intnx ( "month3.2" , dt, 1 ) ;
1083 y3 = intnx ( "month3.3" , dt, 0 ) ;
1084 put dt= / (x1 z1 x2-x5) (=) / (y1 z2 y2-y3) (=) ;
1085 dt = intnx ( "month" , dt , 1) ;
1086 end ;
1087 format _all_ date9. ;
1088 run ;
dt=01JAN2002
x1=01SEP2001 z1=01FEB2002 x2=01OCT2001 x3=01NOV2001 x4=01DEC2001
x5=01JAN2002
y1=01JAN2002 z2=01JAN2002 y2=01FEB2002 y3=01DEC2001
dt=01FEB2002
x1=01FEB2002 z1=01JUL2002 x2=01OCT2001 x3=01NOV2001 x4=01DEC2001
x5=01JAN2002
y1=01JAN2002 z2=01JAN2002 y2=01MAY2002 y3=01DEC2001
dt=01MAR2002
x1=01FEB2002 z1=01JUL2002 x2=01MAR2002 x3=01NOV2001 x4=01DEC2001
x5=01JAN2002
y1=01JAN2002 z2=01JAN2002 y2=01MAY2002 y3=01MAR2002
dt=01APR2002
x1=01FEB2002 z1=01JUL2002 x2=01MAR2002 x3=01APR2002 x4=01DEC2001
x5=01JAN2002
y1=01APR2002 z2=01APR2002 y2=01MAY2002 y3=01MAR2002
dt=01MAY2002
x1=01FEB2002 z1=01JUL2002 x2=01MAR2002 x3=01APR2002 x4=01MAY2002
x5=01JAN2002
y1=01APR2002 z2=01APR2002 y2=01AUG2002 y3=01MAR2002
dt=01JUN2002
x1=01FEB2002 z1=01JUL2002 x2=01MAR2002 x3=01APR2002 x4=01MAY2002
x5=01JUN2002
y1=01APR2002 z2=01APR2002 y2=01AUG2002 y3=01JUN2002
dt=01JUL2002
x1=01JUL2002 z1=01DEC2002 x2=01MAR2002 x3=01APR2002 x4=01MAY2002
x5=01JUN2002
y1=01JUL2002 z2=01JUL2002 y2=01AUG2002 y3=01JUN2002
dt=01AUG2002
x1=01JUL2002 z1=01DEC2002 x2=01AUG2002 x3=01APR2002 x4=01MAY2002
x5=01JUN2002
y1=01JUL2002 z2=01JUL2002 y2=01NOV2002 y3=01JUN2002
dt=01SEP2002
x1=01JUL2002 z1=01DEC2002 x2=01AUG2002 x3=01SEP2002 x4=01MAY2002
x5=01JUN2002
y1=01JUL2002 z2=01JUL2002 y2=01NOV2002 y3=01SEP2002
dt=01OCT2002
x1=01JUL2002 z1=01DEC2002 x2=01AUG2002 x3=01SEP2002 x4=01OCT2002
x5=01JUN2002
y1=01OCT2002 z2=01OCT2002 y2=01NOV2002 y3=01SEP2002
dt=01NOV2002
x1=01JUL2002 z1=01DEC2002 x2=01AUG2002 x3=01SEP2002 x4=01OCT2002
x5=01NOV2002
y1=01OCT2002 z2=01OCT2002 y2=01FEB2003 y3=01SEP2002
dt=01DEC2002
x1=01DEC2002 z1=01MAY2003 x2=01AUG2002 x3=01SEP2002 x4=01OCT2002
x5=01NOV2002
y1=01OCT2002 z2=01OCT2002 y2=01FEB2003 y3=01DEC2002
NOTE: DATA statement used:
real time 0.05 seconds
So hit me with understanding. What have I got, and why do I want it?
IanWhitlock@westat.com
-----Original Message-----
From: Rob Rohrbough [mailto:Rob@ROHRBOUGH-SYSTEMS.COM]
Sent: Thursday, October 31, 2002 11:04 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: HOWTO find last Friday of month?
Floyd, is that a paper manual? For those of us less financially gifted (via
ourselves or our employer), the paper manuals are not in our stable. I had
hoped that both the HTML and the PDF docs would be complete.
Rob
-----Original Message-----
From: Nevseta, Floyd G [mailto:Floyd.G.Nevseta@bankofamerica.com]
Sent: Thursday, October 31, 2002 9:41 AM
To: 'Rob Rohrbough'; SAS-L@LISTSERV.UGA.EDU
Subject: RE: HOWTO find last Friday of month?
It's in SAS Language Reference: Concepts; Part 1: SAS System Concepts;
Dates, Times, and Intervals.
-----Original Message-----
From: Rob Rohrbough [mailto:Rob@ROHRBOUGH-SYSTEMS.COM]
Sent: Thursday, October 31, 2002 10:14 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: HOWTO find last Friday of month?
Can anyone tell me where the dot notation on the interval is documented?
OK, I answered myself by digging into my paper documenation, Technical
Report P-222, page 5 - where I had a, dusty, yellow sticky labeled
"date/time intervals".
Looked there only after I had convinced myself that on-line help for SAS
8.2, the CD documentation, and SAS's website did not contain it. Am I
wrong? Is this valuable documentation available in one of these sources?
If not, is there a little birdie listening who could fix it?
TIA,
Rob
"Stig Eide" <stigeide@yahoo.com> wrote in message
news:faa59d77.0210301427.642e1b1a@posting.google.com...
> "roland.rashleigh-berry" <roland.rashleigh-berry@ntlworld.com> wrote in
message news:<yvPv9.1455$pI2.67153@newsfep1-win.server.ntli.net>...
> > Will this do it?
> >
> > Use the date of the first of the following month and apply this.
> >
> > lastfri=intnx('week.6',date-1,0);
> >
> >
> > "Stig Eide" <stigeide@yahoo.com> wrote in message
> > news:faa59d77.0210300300.2fef0ad4@posting.google.com...
> > > Does anyone have a tip of how to find the last Friday of a month?
> > >
> > > The last day of the month can be found with the INTNX function:
> > > lastDay=intnx('month',today(),0,'E');
> > > This gives the SAS date value of the last day of the current month.
> > >
> > > Anyone have a suggestion?
> > >
> > > Thanks!
> > > Stig Eide
>
> Roland, it gives november 2001 wrong (if date means last date of month):
>
> 40 data _null_;
> 41 lastDay=intnx('month',mdy(11,1,2001),0,'E');
> 42 lastfri=intnx('week.6',lastDay-1,0)+7;
> 43 put lastfri weekdatx. -L;
> 44 run;
>
> Friday, 30 November 2001
> NOTE: DATA statement used:
> real time 0.05 seconds
You have changed my code. This is not what I originally wrote.
I wrote:
> > Use the date of the first of the following month and apply this.
> >
> > lastfri=intnx('week.6',date-1,0);
So if you do:
49 data _null_;
50 lastfri=intnx('week.6','01dec2001'd-1,0);
51 put lastfri=weekdate26.;
52 run;
lastfri=Friday, Nov 30, 2001
NOTE: DATA statement used:
real time 0.04 seconds
This is definitely the last Friday in November 2001.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic