LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 20 Mar 2006 08:13:26 -0800
Reply-To:     "Terjeson, Mark (IM&R)" <Mterjeson@RUSSELL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Terjeson, Mark (IM&R)" <Mterjeson@RUSSELL.COM>
Subject:      Re: Calculate prior dates value
Comments: To: Tom.Salwa@GMAIL.COM
Content-Type: text/plain; charset="US-ASCII"

Hi Tom,

* if var is string ; data _null_; Interaction_date = '20060320';

* convert from string to numeric date ; numdate = input(Interaction_date,yymmdd8.);

hist_date = intnx('day',numdate, -30); * is the same as ; hist_date = numdate - 30; * since numeric date is in days ;

format numdate yymmdd10.; format hist_date yymmdd10.;

* if needed back in character you can ; * convert back to string again ; str_hist_date = put(numdate - 30,yymmddn8.);

put _all_; run;

* if var is numeric ; data _null_; Interaction_date = '20MAR2006'd;

hist_date = intnx('day',Interaction_date, -30); * is the same as ; hist_date = Interaction_date - 30; * since numeric date is in days ;

format Interaction_date yymmdd10.; format hist_date yymmdd10.; put _all_; run;

You may wish to check the documentation on the INTNX() function and check out the other units of measure such as 'month' and also the alignment argument to fold to beginning, middle, or end of unit, etc.

Hope this is helpful.

Mark Terjeson Senior Programmer Analyst, IM&R Russell Investment Group

Russell Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom.Salwa@GMAIL.COM Sent: Monday, March 20, 2006 7:51 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Calculate prior dates value

Hi,

I have an interaction date in the format YYYYMMDD. I am trying to look at the history data 30 days back. For this, i need to calculate the date 30 days prior to the current date. I was looking at the date functions but could not find something close that would help. Any ideas.

Thanks,

Tom

/* Calcualte 30 days prior to the current date */ format Interaction_date $CHAR8.; hist_date = Interaction_date - 30;


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