data olddate;
format date ddmmyy10.;
input date ddmmyy10.;
cards; 12/06/1995 ;
run;
I want to change the year value (which is 1995) to 1996 without
converting the variable to character.
Any help is appreciated.
|
|
0
|
|
|
|
Reply
|
SAS
|
8/20/2010 1:41:12 PM |
|
One way would be:
data olddate;
format date ddmmyy10.;
input date ddmmyy10.;
date=3Dmdy(month(date),day(date),year(date)+1);
cards;
12/06/1995
;
HTH,
Art
----------
On Aug 20, 9:41=A0am, SAS programmer <learnsasonl...@gmail.com> wrote:
> data olddate;
> format date ddmmyy10.;
> input date ddmmyy10.;
> cards; 12/06/1995 ;
> run;
>
> I want to change the year value (which is 1995) to 1996 without
> converting the variable to character.
> Any help is appreciated.
|
|
0
|
|
|
|
Reply
|
Arthur
|
8/20/2010 1:47:10 PM
|
|
A better solution was offered on SAS-L:
On Fri, 20 Aug 2010 09:24:41 -0500, Joe Matise <snoopy369@GMAIL.COM>
wrote:
>I would suggest the INTNX function, with the 's' flag for 'same':
>
>data olddate;
> format date newdate ddmmyy10.;
> input date ddmmyy10.;
> newdate=3Dintnx('YEAR',date,1,'s');
> put newdate=3D;
> cards;
>12/06/1995
>;
>run;
The code I suggested would fail if confronted with a date of Feb 29th.
Art
-----------
On Aug 20, 9:47=A0am, Arthur Tabachneck <art...@netscape.net> wrote:
> One way would be:
>
> data olddate;
> =A0 format date ddmmyy10.;
> =A0 input date ddmmyy10.;
> =A0 date=3Dmdy(month(date),day(date),year(date)+1);
> =A0 cards;
> 12/06/1995
> ;
>
> HTH,
> Art
> ----------
> On Aug 20, 9:41=A0am, SAS programmer <learnsasonl...@gmail.com> wrote:
>
>
>
> > data olddate;
> > format date ddmmyy10.;
> > input date ddmmyy10.;
> > cards; 12/06/1995 ;
> > run;
>
> > I want to change the year value (which is 1995) to 1996 without
> > converting the variable to character.
> > Any help is appreciated.- Hide quoted text -
>
> - Show quoted text -
|
|
0
|
|
|
|
Reply
|
art297 (4237)
|
8/20/2010 2:42:19 PM
|
|
While you already have an answer to your question, I have to ask:
"What is it that you are trying to do?"
I ask because 1996 happens to be the year my office currently uses to
roll up our data so that it only reflects a 15 year window (i.e.,
everything happening before 1996 is rolled up into a bucket labeled
1996).
If you are doing a similar operation then more is involved than just
an algorithm to change a date and many of us could provide further
reflections of our own experience.
Art
-------------
On Aug 20, 10:42 am, Arthur Tabachneck <art...@netscape.net> wrote:
> A better solution was offered on SAS-L:
>
> On Fri, 20 Aug 2010 09:24:41 -0500, Joe Matise <snoopy...@GMAIL.COM>
> wrote:
>
> >I would suggest the INTNX function, with the 's' flag for 'same':
>
> >data olddate;
> > format date newdate ddmmyy10.;
> > input date ddmmyy10.;
> > newdate=intnx('YEAR',date,1,'s');
> > put newdate=;
> > cards;
> >12/06/1995
> >;
> >run;
>
> The code I suggested would fail if confronted with a date of Feb 29th.
>
> Art
> -----------
> On Aug 20, 9:47 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
>
>
> > One way would be:
>
> > data olddate;
> > format date ddmmyy10.;
> > input date ddmmyy10.;
> > date=mdy(month(date),day(date),year(date)+1);
> > cards;
> > 12/06/1995
> > ;
>
> > HTH,
> > Art
> > ----------
> > On Aug 20, 9:41 am, SAS programmer <learnsasonl...@gmail.com> wrote:
>
> > > data olddate;
> > > format date ddmmyy10.;
> > > input date ddmmyy10.;
> > > cards; 12/06/1995 ;
> > > run;
>
> > > I want to change the year value (which is 1995) to 1996 without
> > > converting the variable to character.
> > > Any help is appreciated.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
|
|
0
|
|
|
|
Reply
|
art297 (4237)
|
8/20/2010 10:39:05 PM
|
|
On Aug 20, 6:39=A0pm, Arthur Tabachneck <art...@netscape.net> wrote:
> While you already have an answer to your question, I have to ask:
> "What is it that you are trying to do?"
>
> I ask because 1996 happens to be the year my office currently uses to
> roll up our data so that it only reflects a 15 year window (i.e.,
> everything happening before 1996 is rolled up into a bucket labeled
> 1996).
>
> If you are doing a similar operation then more is involved than just
> an algorithm to change a date and many of us could provide further
> reflections of our own experience.
>
> Art
> -------------
> On Aug 20, 10:42 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
>
>
> > A better solution was offered on SAS-L:
>
> > On Fri, 20 Aug 2010 09:24:41 -0500, Joe Matise <snoopy...@GMAIL.COM>
> > wrote:
>
> > >I would suggest the INTNX function, with the 's' flag for 'same':
>
> > >data olddate;
> > > format date newdate ddmmyy10.;
> > > input date ddmmyy10.;
> > > newdate=3Dintnx('YEAR',date,1,'s');
> > > put newdate=3D;
> > > cards;
> > >12/06/1995
> > >;
> > >run;
>
> > The code I suggested would fail if confronted with a date of Feb 29th.
>
> > Art
> > -----------
> > On Aug 20, 9:47 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
> > > One way would be:
>
> > > data olddate;
> > > =A0 format date ddmmyy10.;
> > > =A0 input date ddmmyy10.;
> > > =A0 date=3Dmdy(month(date),day(date),year(date)+1);
> > > =A0 cards;
> > > 12/06/1995
> > > ;
>
> > > HTH,
> > > Art
> > > ----------
> > > On Aug 20, 9:41 am, SAS programmer <learnsasonl...@gmail.com> wrote:
>
> > > > data olddate;
> > > > format date ddmmyy10.;
> > > > input date ddmmyy10.;
> > > > cards; 12/06/1995 ;
> > > > run;
>
> > > > I want to change the year value (which is 1995) to 1996 without
> > > > converting the variable to character.
> > > > Any help is appreciated.- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Art,
It's a part of data cleaning work. DM team identified that the YEAR
value for one particular patient entered wrong in the database. I need
to convert the year value 1995 to 1996 (for date variables) for one
particular patient.
Thanks again for the help.
Thanks,
Sarath
|
|
0
|
|
|
|
Reply
|
learnsasonline (22)
|
8/21/2010 6:11:51 PM
|
|
On Aug 21, 11:11=A0am, SAS programmer <learnsasonl...@gmail.com> wrote:
> On Aug 20, 6:39=A0pm, Arthur Tabachneck <art...@netscape.net> wrote:
>
>
>
>
>
> > While you already have an answer to your question, I have to ask:
> > "What is it that you are trying to do?"
>
> > I ask because 1996 happens to be the year my office currently uses to
> > roll up our data so that it only reflects a 15 year window (i.e.,
> > everything happening before 1996 is rolled up into a bucket labeled
> > 1996).
>
> > If you are doing a similar operation then more is involved than just
> > an algorithm to change a date and many of us could provide further
> > reflections of our own experience.
>
> > Art
> > -------------
> > On Aug 20, 10:42 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
> > > A better solution was offered on SAS-L:
>
> > > On Fri, 20 Aug 2010 09:24:41 -0500, Joe Matise <snoopy...@GMAIL.COM>
> > > wrote:
>
> > > >I would suggest the INTNX function, with the 's' flag for 'same':
>
> > > >data olddate;
> > > > format date newdate ddmmyy10.;
> > > > input date ddmmyy10.;
> > > > newdate=3Dintnx('YEAR',date,1,'s');
> > > > put newdate=3D;
> > > > cards;
> > > >12/06/1995
> > > >;
> > > >run;
>
> > > The code I suggested would fail if confronted with a date of Feb 29th=
..
>
> > > Art
> > > -----------
> > > On Aug 20, 9:47 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
> > > > One way would be:
>
> > > > data olddate;
> > > > =A0 format date ddmmyy10.;
> > > > =A0 input date ddmmyy10.;
> > > > =A0 date=3Dmdy(month(date),day(date),year(date)+1);
> > > > =A0 cards;
> > > > 12/06/1995
> > > > ;
>
> > > > HTH,
> > > > Art
> > > > ----------
> > > > On Aug 20, 9:41 am, SAS programmer <learnsasonl...@gmail.com> wrote=
:
>
> > > > > data olddate;
> > > > > format date ddmmyy10.;
> > > > > input date ddmmyy10.;
> > > > > cards; 12/06/1995 ;
> > > > > run;
>
> > > > > I want to change the year value (which is 1995) to 1996 without
> > > > > converting the variable to character.
> > > > > Any help is appreciated.- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
>
> Art,
>
> It's a part of data cleaning work. DM team identified that the YEAR
> value for one particular patient entered wrong in the database. I need
> to convert the year value 1995 to 1996 (for date variables) for one
> particular patient.
>
> Thanks again for the help.
>
> Thanks,
> Sarath
You should use If then statement if you want to apply for one
observation which is called conditional logic.
If Name =3D ' patient name' then make date=3D1996;
OR You can use a combination of variables in order to get it done
|
|
0
|
|
|
|
Reply
|
Rama21st (2)
|
8/23/2010 1:11:40 AM
|
|
On Aug 22, 9:11=A0pm, shilpa <rama2...@gmail.com> wrote:
> On Aug 21, 11:11=A0am, SAS programmer <learnsasonl...@gmail.com> wrote:
>
>
>
>
>
> > On Aug 20, 6:39=A0pm, Arthur Tabachneck <art...@netscape.net> wrote:
>
> > > While you already have an answer to your question, I have to ask:
> > > "What is it that you are trying to do?"
>
> > > I ask because 1996 happens to be the year my office currently uses to
> > > roll up our data so that it only reflects a 15 year window (i.e.,
> > > everything happening before 1996 is rolled up into a bucket labeled
> > > 1996).
>
> > > If you are doing a similar operation then more is involved than just
> > > an algorithm to change a date and many of us could provide further
> > > reflections of our own experience.
>
> > > Art
> > > -------------
> > > On Aug 20, 10:42 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
> > > > A better solution was offered on SAS-L:
>
> > > > On Fri, 20 Aug 2010 09:24:41 -0500, Joe Matise <snoopy...@GMAIL.COM=
>
> > > > wrote:
>
> > > > >I would suggest the INTNX function, with the 's' flag for 'same':
>
> > > > >data olddate;
> > > > > format date newdate ddmmyy10.;
> > > > > input date ddmmyy10.;
> > > > > newdate=3Dintnx('YEAR',date,1,'s');
> > > > > put newdate=3D;
> > > > > cards;
> > > > >12/06/1995
> > > > >;
> > > > >run;
>
> > > > The code I suggested would fail if confronted with a date of Feb 29=
th.
>
> > > > Art
> > > > -----------
> > > > On Aug 20, 9:47 am, Arthur Tabachneck <art...@netscape.net> wrote:
>
> > > > > One way would be:
>
> > > > > data olddate;
> > > > > =A0 format date ddmmyy10.;
> > > > > =A0 input date ddmmyy10.;
> > > > > =A0 date=3Dmdy(month(date),day(date),year(date)+1);
> > > > > =A0 cards;
> > > > > 12/06/1995
> > > > > ;
>
> > > > > HTH,
> > > > > Art
> > > > > ----------
> > > > > On Aug 20, 9:41 am, SAS programmer <learnsasonl...@gmail.com> wro=
te:
>
> > > > > > data olddate;
> > > > > > format date ddmmyy10.;
> > > > > > input date ddmmyy10.;
> > > > > > cards; 12/06/1995 ;
> > > > > > run;
>
> > > > > > I want to change the year value (which is 1995) to 1996 without
> > > > > > converting the variable to character.
> > > > > > Any help is appreciated.- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
> > Art,
>
> > It's a part of data cleaning work. DM team identified that the YEAR
> > value for one particular patient entered wrong in the database. I need
> > to convert the year value 1995 to 1996 (for date variables) for one
> > particular patient.
If it is a single observation, I could have used IF-THEN clause... But
it's not.
sarath
> > Thanks again for the help.
>
> > Thanks,
> > Sarath
>
> You should use If then statement if you want to apply for one
> observation which is called conditional logic.
>
> If Name =3D ' patient name' then make date=3D1996;
>
> OR You can use a combination of variables in order to get it done- Hide q=
uoted text -
>
> - Show quoted text -
|
|
0
|
|
|
|
Reply
|
learnsasonline (22)
|
10/3/2010 2:19:31 PM
|
|
|
6 Replies
285 Views
(page loaded in 0.114 seconds)
|