From: QiJun Fung on
Hi all,

I am very sorry to bother you again. I encounter a problem recently. I
just tried what I know, but still can not figure it out.

I have a variable called date in my date set with format datetime19.
like "17NOV2008:00:00:00". Now I only want month and year format
yymm. like"2008M11". I use the following code:

data one;
format date2 yymm.;
date2=put(date, yymm.);
run;

However, it did not work since in date2 column it shows
'***********'. And another thing I was very confused is what is the
difference between format and informat. Do I need to use informat
statement to change the variable's format?

Can anyone give me some hint? Thanks very much for your time.

Have a good weekend!
From: Mo Yang on
I think it's input function not put function. Try input function.
On Apr 9, 2:52 pm, QiJun Fung <coolc...(a)gmail.com> wrote:
> Hi all,
>
> I am very sorry to bother you again. I encounter a problem recently. I
> just tried what I know, but still can not figure it out.
>
> I  have a variable called date in my date set with format datetime19.
> like  "17NOV2008:00:00:00". Now I only want month and year format
> yymm.  like"2008M11". I use the following code:
>
> data one;
> format date2 yymm.;
> date2=put(date, yymm.);
> run;
>
> However, it did not work since in date2 column it shows
> '***********'.  And another thing I was very confused is what is the
> difference between format and informat. Do I need to use informat
> statement to change the variable's format?
>
> Can anyone give me some hint? Thanks very much for your time.
>
> Have a good weekend!

From: Barry Schwarz on
What you have makes date2 a character variable. yymm is a numeric
format which should only be used with numeric variables.

Since the data is in a datetime variable and you want to process only
the date part, try
date2 = datepart(date);

On Fri, 9 Apr 2010 12:52:29 -0700 (PDT), QiJun Fung
<coolcong(a)gmail.com> wrote:

>Hi all,
>
>I am very sorry to bother you again. I encounter a problem recently. I
>just tried what I know, but still can not figure it out.
>
>I have a variable called date in my date set with format datetime19.
>like "17NOV2008:00:00:00". Now I only want month and year format
>yymm. like"2008M11". I use the following code:
>
>data one;
>format date2 yymm.;
>date2=put(date, yymm.);
>run;
>
>However, it did not work since in date2 column it shows
>'***********'. And another thing I was very confused is what is the
>difference between format and informat. Do I need to use informat
>statement to change the variable's format?
>
>Can anyone give me some hint? Thanks very much for your time.
>
>Have a good weekend!

--
Remove del for email