| Date: | Wed, 9 Dec 2009 07:21:34 -0800 |
| Reply-To: | Elysia Larson <elysia.larson@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Elysia Larson <elysia.larson@GMAIL.COM> |
| Organization: | http://groups.google.com |
| Subject: | Re: calculations using dates stored with an apostrophe at the
start |
|
| Content-Type: | text/plain; charset=ISO-8859-1 |
It worked! Thank you!
On Dec 9, 9:38 am, Tom Abernathy <tom.aberna...@gmail.com> wrote:
> Elysia -
> The leading apostrophe is telling Excel to treat the value as a CHAR
> string even if it looks like a number.
> In SAS to convert the string to a data value use the INPUT
> function. You can then apply a format to this new numeric variable.
> So if you column in Excel is named DATE1 you could generate a new
> variable in SAS named SASDATE1 with these statements.
>
> sasdate1 = input(date1,date11.);
> format sasdate1 date11.;
>
> - Tom
>
> On Dec 9, 7:57 am, Elysia Larson <elysia.lar...@gmail.com> wrote:
>
> > Hi,
>
> > I have an excel spreadsheet with three variables: an ID and two
> > dates. The dates are stored as 'DD-MMM-YY with the apostrophe at the
> > beginning. When I read the file into SAS it does not read in the
> > apostrophe, yet reads in the dates as characters. I need to do
> > calculations on the dates, but when I try to format them as dates it
> > won't let. When I export the data into a new spreadsheet it again
> > includes the apostrophe. I tried to do a substr to remove the
> > apostrophe, but it just removed the first number of the date.
>
> > Suggestions on how to convert these variables into dates that SAS will
> > recognize?
>
> > Thank you,
>
> > Elysia
|