Sorting date variable

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Sorting date variable

E. Bernardo
How to sort date variable? The date is in mm yyyy format? I tried this syntax but it failed:
SORT CASES BY
Date3 (D) .
 
Thanks.
Eins


Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Sorting date variable

ViAnn Beadle

In what way did it fail?

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Eins Bernardo
Sent: Wednesday, April 15, 2009 9:37 PM
To: [hidden email]
Subject: Sorting date variable

 

How to sort date variable? The date is in mm yyyy format? I tried this syntax but it failed:

SORT CASES BY

Date3 (D) .

 

Thanks.

Eins

 


Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.

Reply | Threaded
Open this post in threaded view
|

Re: Sorting date variable

E. Bernardo
In reply to this post by E. Bernardo
I already solved that. Thank you for your immediate reply.
One more problem.  I want to sort the year in descending order while the month in ascending. Can we do this?


--- On Thu, 4/16/09, ViAnn Beadle <[hidden email]> wrote:

From: ViAnn Beadle <[hidden email]>
Subject: RE: Sorting date variable
To: "'Eins Bernardo'" <[hidden email]>, [hidden email]
Date: Thursday, 16 April, 2009, 3:52 AM

In what way did it fail?

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Eins Bernardo
Sent: Wednesday, April 15, 2009 9:37 PM
To: [hidden email]
Subject: Sorting date variable

 

How to sort date variable? The date is in mm yyyy format? I tried this syntax but it failed:

SORT CASES BY

Date3 (D) .

 

Thanks.

Eins

 


Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.



Surf faster.
Internet Explorer 8 optmized for Yahoo! auto launches 2 of your favorite pages everytime you open your browser.Get IE8 here! (It's free)
Reply | Threaded
Open this post in threaded view
|

Re: Sorting date variable

Albert-Jan Roskam
In reply to this post by E. Bernardo
Hi!

You can extract year and month, then sort it:
compute y = xdate.year(datevar).
compute m = xdate.month(datevar).
sort cases by y (d) m (a).

Cheers!!
Albert-Jan

--- On Thu, 4/16/09, Eins Bernardo <[hidden email]> wrote:

> From: Eins Bernardo <[hidden email]>
> Subject: Re: Sorting date variable
> To: [hidden email]
> Date: Thursday, April 16, 2009, 7:21 AM
> I
> already solved that. Thank you for your immediate
> reply.
> One more problem.  I want to sort the year in
> descending order while the month in ascending. Can we do
> this?
>
>
> --- On Thu, 4/16/09, ViAnn Beadle
> <[hidden email]> wrote:
>
>
> From: ViAnn Beadle <[hidden email]>
> Subject: RE: Sorting date variable
> To: "'Eins Bernardo'"
> <[hidden email]>, [hidden email]
> Date: Thursday, 16 April, 2009, 3:52 AM
>
>
>
>
>
>
>
>
> In what way did it fail?
>
>
> From:
> SPSSX(r) Discussion [mailto:[hidden email]] On
> Behalf Of Eins Bernardo
> Sent: Wednesday, April 15, 2009 9:37 PM
> To: [hidden email]
> Subject: Sorting date variable
>
>
>
>
>
>
> How to sort date variable? The date
> is in mm yyyy format? I tried this syntax but it
> failed:
>
> SORT
> CASES BY
>
> Date3
> (D) .
>
>
>
> Thanks.
>
> Eins
>
>
>
>
> Get
> your preferred Email name!
> Now you can @ymail.com and
> @rocketmail.com.
>
>
> Surf faster.
>  Internet Explorer 8 optmized for Yahoo! auto launches 2 of
> your favorite pages everytime you open your browser.Get
> IE8 here! (It's free)

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Sorting date variable

ViAnn Beadle
In reply to this post by E. Bernardo

You would have to split up the date into year and month components using the xdate functions and then sort on the components. Look up xdate in help.

 

 

From: Eins Bernardo [mailto:[hidden email]]
Sent: Wednesday, April 15, 2009 11:22 PM
To: [hidden email]; ViAnn Beadle
Subject: RE: Sorting date variable

 

I already solved that. Thank you for your immediate reply.

One more problem.  I want to sort the year in descending order while the month in ascending. Can we do this?



--- On Thu, 4/16/09, ViAnn Beadle <[hidden email]> wrote:


From: ViAnn Beadle <[hidden email]>
Subject: RE: Sorting date variable
To: "'Eins Bernardo'" <[hidden email]>, [hidden email]
Date: Thursday, 16 April, 2009, 3:52 AM

In what way did it fail?

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Eins Bernardo
Sent: Wednesday, April 15, 2009 9:37 PM
To: [hidden email]
Subject: Sorting date variable

 

How to sort date variable? The date is in mm yyyy format? I tried this syntax but it failed:

SORT CASES BY

Date3 (D) .

 

Thanks.

Eins

 


Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.

 


Surf faster.
Internet Explorer 8 optmized for Yahoo! auto launches 2 of your favorite pages everytime you open your browser.Get IE8 here! (It's free)