Date: Sun, 21 Sep 2008 19:53:00 -0700
Reply-To: sri <sri114in@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: sri <sri114in@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: date format
Content-Type: text/plain; charset=ISO-8859-1
Thank you so much for your replys. I have conmed data with start dates
in ISO8601 format.
Some of the observations have partial dates. I was asked to create
analysis data sets with start
date in date9. formats with out actually imputing dates and people
want to look at the original dates in date9. format.
Thank you Arthur & Data_null_ for suggesting the best possible ways.
On Sep 21, 7:14 am, iebup...@GMAIL.COM ("./ ADD NAME=Data _null_,")
wrote:
> I would think the format YYYYMMDD would be best for display of partial
> dates. This is basically the ISO8601 date format which I believe
> allows for partials dates in this style. I can see no good reason for
> the OPs request. Especially given "his" unwillingness to use imputed
> dates which is the only way to "convert" to SAS dates.
>
> On 9/20/08, Arthur Tabachneck <art...@netscape.net> wrote:
>
>
>
> > Sri,
>
> > I'm not sure what you are trying to obtain. The code I suggested
> > translates your sample data into the format you indicated that you
> > wanted.
>
> > If you are looking for a SAS date that only has the value 2006 or
> > JUL2006, I don't believe that can be achieved.
>
> > You could get separate fields for year, month and day. Is that what
> > you are looking for?
>
> > If so, try the following:
>
> > data Have ;
> > input evtdate $20.;
> > datalines;
> > 2006-08-20
> > 2006-06-11
> > 2006-07
> > 2006
> > ;
>
> > data want (drop=datein evtdt type);
> > set have (rename=(evtdate=datein));
> > evtdt=input(datein,ANYDTDTE20.);
> > if missing(evtdt) then do;
> > evtdt=input(catt(datein,'-01'),ANYDTDTE20.);
> > if missing(evtdt) then do;
> > evtdt=input(catt(datein,'-01-01'),ANYDTDTE20.);
> > year=year(evtdt);
> > call missing(month);
> > call missing(day);
> > type=3;
> > end;
> > else do;
> > year=year(evtdt);
> > month=month(evtdt);
> > call missing(day);
> > type=2;
> > end;
> > end;
> > else do;
> > type=1;
> > year=year(evtdt);
> > month=month(evtdt);
> > day=day(evtdt);
> > end;
> > if type=1 then evtdate=put(evtdt,date9.);
> > else if type=2 then evtdate=substr(put(evtdt,date9.),3);
> > else if type=3 then evtdate=datein;
> > run;
> > proc print data=want;
> > run;
>
> > Art
> > ---------
> > On Sep 20, 11:45 pm, sri <sri11...@gmail.com> wrote:
> > > Thanks you very much for your reply
> > > I tried with your code but for
> > > for partial dates like this I am not getting desired output.
> > > Is there any way that we can get the desired output with out actually
> > > imputing dates.
> > > Because in my data I have lot of partial dates. I canot impute values
> > > to these dates.
> > > For example for dates like this
> > > 2006-07
> > > 2006
>
> > > I need to get
> > > JUL2006
> > > 2006
>
> > > On Sep 19, 8:18 pm, art...@NETSCAPE.NET (Arthur Tabachneck) wrote:
>
> > > > Sri,
>
> > > > Sorry, I hadn't payed enough attention to your expressed desired output.
> > > > Try:
>
> > > > data Have ;
> > > > input evtdate $20.;
> > > > datalines;
> > > > 2006-08-20
> > > > 2006-06-11
> > > > 2006-07
> > > > 2006
> > > > ;
>
> > > > data want (drop=datein evtdt type);
> > > > set have (rename=(evtdate=datein));
> > > > evtdt=input(datein,ANYDTDTE20.);
> > > > if missing(evtdt) then do;
> > > > evtdt=input(catt(datein,'-01'),ANYDTDTE20.);
> > > > if missing(evtdt) then do;
> > > > evtdt=input(catt(datein,'-01-01'),ANYDTDTE20.);
> > > > type=3;
> > > > end;
> > > > else type=2;
> > > > end;
> > > > else type=1;
> > > > if type=1 then evtdate=put(evtdt,date9.);
> > > > else if type=2 then evtdate=substr(put(evtdt,date9.),3);
> > > > else if type=3 then evtdate=datein;
> > > > run;
>
> > > > Art
> > > > -------
>
> > > > On Fri, 19 Sep 2008 15:02:12 -0700, sri <sri11...@GMAIL.COM> wrote:
> > > > >data Have ;
> > > > >input evtdate $20.;
> > > > >datalines;
> > > > >2006-08-20
> > > > >2006-06-11
> > > > >2006-07
> > > > >2006
> > > > >;
> > > > >Wanted
> > > > >20AUG2006
> > > > >11JUN2006
> > > > >JUL2006
> > > > >2006- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
|