| Date: | Tue, 5 Jan 2010 16:12:06 -0500 |
| Reply-To: | Jack Clark <jclark@HILLTOP.UMBC.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Jack Clark <jclark@HILLTOP.UMBC.EDU> |
| Subject: | Re: chop dates into month |
|
| In-Reply-To: | A<5947c4ba-6838-4791-90ea-876283cc204f@c3g2000yqd.googlegroups.com> |
| Content-Type: | text/plain; charset="us-ascii" |
Larry,
The INTCK and INTNX functions will help you with this type of task. You
can read up on them in the SAS documentation.
data have;
id = 1;
begin = '18JUN07'd;
end = '28SEP07'd;
run;
data need (drop=i);
set have;
do i = 0 to intck('MONTH',begin,end);
bdate = intnx('MONTH',begin,i,'B');
edate = intnx('MONTH',begin,i,'E');
output;
end;
format begin end bdate edate mmddyy8.;
run;
proc print data = need;
format bdate mmddyy8.;
run;
Jack Clark
Senior Research Analyst
phone: 410-455-6256
fax: 410-455-6850
jclark@hilltop.umbc.edu
University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250
Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Larry
Sent: Tuesday, January 05, 2010 3:50 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: chop dates into month
Dear SAS-L,
I am doing data manipulation but stuck by this issue. I have data
like;
id begin end ;
1 06/18/07 09/28/07;
I want my data to be chopped by month, so desired data will be like;
id begin end bdate edate
1 06/18/07 09/28/07 06/01/07 06/30/07
1 06/18/07 09/28/07 07/01/07 07/31/07
1 06/18/07 09/28/07 08/01/07 08/31/07
1 06/18/07 09/28/07 09/01/07 09/31/07
Any advice will be appreciated.
|