Date: Thu, 22 Mar 2012 18:51:21 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: quoting in SYSFUNC vs data step
Content-Type: text/plain; charset="Windows-1252"
Well heck I did mix the E and B up, thanks for the catch...
The Reason this doesnt work:
%put %SysFunc( IntnX( 'Month', '01Mar2012'd , 0 , 'E' ) );
Is because your working in the macro language and not the data step language.
In the data step language words have meaning ( Data Run quit set merge etc...)
so we there for have to specify thos words we dont want interpreted by surounding
the, with quotes. In the macro language everything is considered not to have meaning
and just text. Therefore we have to tell SAS which words to interpret as having meaning
by prefixing with & and %.
Now my guess is the qoutes screw with the macro interface into the data step facility, which
is what %Sysfunc was designed to do. Trust me this isnt first nor the only data step function that
%sysfunc screws things up when the function is given qouted values
If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain.
“Any idiot can face a crisis—it’s day to day living that wears you out”
~ Anton Chekhov
> Subject: quoting in SYSFUNC vs data step
> Date: Thu, 22 Mar 2012 14:42:43 -0400
> From: YBolotin@schools.nyc.gov
> To: tobydunn@HOTMAIL.COM; SAS-L@LISTSERV.UGA.EDU
> Toby is of course absolutely right, except E = end (last day), B =
> beginning (first)
> Slightly off topic - why does this work as written but NOT work if month
> and E/B are quoted? (a data step does the opposite)
> %put %SysFunc( IntnX( Month, '01Mar2012'd , 0 , E ) ); * works - I do
> not understand why ;
> %put %SysFunc( IntnX( 'Month', '01Mar2012'd , 0 , 'E' ) ); *produces
> WARNING: An argument to the function INTNX referenced by the %SYSFUNC or
> %QSYSFUNC macro function is out of range - I do not understand why ;
> data _z;
> a = IntnX( Month , '01Mar2012'd , 0 , E ) ; * complains of
> undefined Month and E, as can be expected ;
> b = IntnX( 'Month' , '01Mar2012'd , 0 , 'E' ) ; * works ;
> format a mmddyy10. b mmddyy10. ;
> put a= b=;
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> toby dunn
> Sent: Thursday, March 22, 2012 2:23 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Urgently Need Macro Help
> %SysFunc( IntnX( Month , "01Mar2012'd , 0 , E ) ) ---->>>> gives yo
> uthe first of the month
> %SysFunc( IntnX( Month , "01Mar2012'd , 0 , B ) ) ----->>>> gives you
> the last day of the month
> Toby Dunn
> If you get thrown from a horse, you have to get up and get back on,
> unless you landed on a cactus; then you have to roll around and scream
> in pain.
> "Any idiot can face a crisis-it's day to day living that wears you out"
> ~ Anton Chekhov
> > Date: Thu, 22 Mar 2012 11:16:00 -0700
> > From: john_rr_irc@YAHOO.COM
> > Subject: Urgently Need Macro Help
> > To: SAS-L@LISTSERV.UGA.EDU
> > Hi All,
> > In the following program I want to read the first day of the current
> month and the last day of the current month
> > dynamically. So, that every month I don't have to change the dates. I
> don't like the idea of hard coding the begin and end date every month.
> > %let begin='01mar12'd; /*** first day of the month ***/
> > %let end ='31mar12'd; /*** last day of the month ***/
> > data daily.Daily_del_&sysdate;
> > set daily.comprehensive_&sysdate;
> > where del_date ge &begin and del_date le &end;
> > run;
> > %mend;
> > Thank you for your help.
> > JRR