| Date: | Wed, 12 Aug 2009 12:55:34 -0700 |
| Reply-To: | "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM> |
| Subject: | Re: Date Type of MM-DD-YYYY and MM-YY |
|
| In-Reply-To: | <3dbdf7ab-68db-4334-a0aa-6300c8ef346d@a13g2000yqc.googlegroups.com> |
| Content-Type: | text/plain; charset="us-ascii" |
You first talk about something staying numeric (as if you expected it to
be converted to character) and then you ask about converting a character
to numeric. Which is it?
A format does not change a variable, not its type, not its value, not
anything. It only determines how the variable is formatted when used in
the PUT statement or PUT function.
If you want to convert a numeric variable (which is how date values are
stored in SAS), you can pass the variable to the PUT function using any
date format you want) and assign the result to a character variable of
suitable length. For converting a character to numeric, you would use
the INPUT function and the appropriate informat.
Is your real question what formats will produce the three different
representations you describe? MM-DD-YYYY is produced by the MMDDYYD10.
format. MM-YY is produced by the MMYYD5. format. MM-YYYY is produced
by the MMYYD. (or the equivalent MMYYD7.) format.
Or is your real question what informats will convert a character of the
specified form to a date value? MM-DD-YYYY can be converted with the
MMDDYY10. informat. MM-YY can be converted by concatenating it after
"01-" and using the DDMMYY8. informat. MM-YYYY can be converted by
performing the same concatenation and using the DDMMYY10. informat.
By the way, how many different names do you intend to post under using
the same email address?
-----Original Message-----
From: Ya Wei
Sent: Wednesday, August 12, 2009 7:13 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Date Type of MM-DD-YYYY and MM-YY
Does anyone know what's the date type of MM-DD-YYYY and MM-YY?
I found MM-DD-YYYY as IS8601DA. but while tyring to convert it, the
field stay as numeric.
I can't find what's the date type for MM-YYYY
Are there any way I can convert them from Charact to Date type?
|