LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2012, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 Mar 2012 22:30:37 +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: Urgently Need Macro Help
Comments: To: mary.rosenbloom.sas@gmail.com
In-Reply-To:  <CAHj_gPfKYYMGjPi6DRK=PXHmknu2Qd+DjR53pe+VTvB+iBRBZQ@mail.gmail.com>
Content-Type: text/plain; charset="Windows-1252"

Data Daily.Daily_Del_%Sysfunc( ToDay() , MONYY7. ) ; Set Daily.Comprehensive_%Sysfunc( ToDay() , MONYY7. ) ; Where ( Intn( 'Month' , ToDay() , 0 , 'B' ) <= Del_Date <= Intn( 'Month' , ToDay() , 0 , 'E' ) ) ; Run ;

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 15:14:02 -0700 > From: mary.rosenbloom.sas@GMAIL.COM > Subject: Re: Urgently Need Macro Help > To: SAS-L@LISTSERV.UGA.EDU > > Bolotin, > > I like your idea of using datetime rather than &sysdate. I didn't give a > lot of thought to the difference. > > Also, I would like to propose one more alternative WHERE statement, using > your date suggestion: > > > *data* daily.Daily_del_&sysdate; > > set daily.comprehensive_&sysdate; > > where month(del_date) eq month(date()) and year(del_date) eq > year(date()); > > *run*; > > It seems that the goal of the original post was just to grab all records > from the current month. So, it seems that it is really only necessary to > match on the month and year values. I would love to see someone show an > IntnX version of this. I'm a newbie with that function. > > Cheers, > Mary R. > On Thu, Mar 22, 2012 at 2:26 PM, Bolotin Yevgeniy > <YBolotin@schools.nyc.gov>wrote: > > > Slightly off-topic: &SYSDATE references the SAS session's launch time, > > so if you keep your session open from e.g. March 29 to April 6, then the > > stuff you run in April will still create variables for March > > > > You may want to use the datetime() function instead - e.g. the following > > example creates today's date as a macro variable, formatted yyyy_mm_dd > > > > data _null_; > > my_dt = datetime(); > > my_d = datepart(my_dt); > > m = put(month(my_d),Z2.); > > y = put(year(my_d),Z4.); > > d = put(day(my_d),Z2.); > > call symput('gl_date_current', cat(y, "_", m, "_", d)); > > run; > > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > > Mary Rosenbloom > > Sent: Thursday, March 22, 2012 5:12 PM > > To: SAS-L@LISTSERV.UGA.EDU > > Subject: Re: Urgently Need Macro Help > > > > John, > > > > Based off of Toby's comment, perhaps you might want to fully automate by > > doing this: > > > > > > /*---->>>> gives you the first of the month*/ > > > > %let begin=%SysFunc( IntnX( Month , "&sysdate"d , 0 , B ) ) ; > > > > /*----->>>> gives you the last day of the month*/ > > > > %let ending=%SysFunc( IntnX( Month , "&sysdate"d , 0 , E ) ) ; > > > > > > > > ***shows values; > > * > > > > data* _null_; > > > > begin=put(&begin,date9.); > > > > put 'Begin is ' begin; > > > > ending=put(&ending,date9.); > > > > put 'End is ' ending; > > * > > > > run*; > > > > ***and in your case; > > * > > > > data* daily.Daily_del_&sysdate; > > > > set daily.comprehensive_&sysdate; > > > > where del_date ge &begin and del_date le &ending; > > * > > > > run*; > > On Thu, Mar 22, 2012 at 11:23 AM, High, Robin R <rhigh@unmc.edu> wrote: > > > > > John, > > > > > > Try putting your macro variables within double quotes: > > > > > > %macro rn; > > > > > > proc print data=sashelp.stocks; > > > where "&dtb"d le date le "&dte"d; > > > run; > > > > > > %mend rn; > > > > > > %let dtb=01Aug89; > > > %let dte=01Aug90; > > > > > > %rn > > > > > > > > > Robin High > > > UNMC > > > > > > > > > -----Original Message----- > > > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > > John > > > RR > > > Sent: Thursday, March 22, 2012 1:16 PM > > > To: SAS-L@LISTSERV.UGA.EDU > > > Subject: Urgently Need Macro Help > > > > > > 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 > > > > > > > > > > > -- > > Cheers, > > Mary F. O. Rosenbloom > > http://www.sascommunity.org/wiki/User:Otterm1 > > > > > > -- > Cheers, > Mary F. O. Rosenbloom > http://www.sascommunity.org/wiki/User:Otterm1


Back to: Top of message | Previous page | Main SAS-L page