Date formats containing quartils and years

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

Date formats containing quartils and years

Eliassen
Hello, I am new to SPSS and I am trying to find out how to get the format of
date correct. I have quartils and years, exemple : 2007_2, but in the date
menu there is no option for this, only q Q yy . What can I do to be able to
get the dates correct when I import from excel ?
Thanks!
Best regards,



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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: Date formats containing quartils and years

Robert L
Given that your date variable after import from Excel is formatted as a string variable, then something like the following should work:

*A small sample dataset.
DATA LIST LIST/qyear(A6).
BEGIN DATA
2017_2
2018_1
2018_3
END DATA.
DATASET NAME date_conversion WINDOW=FRONT.

COMPUTE date=DATE.QYR(NUMBER(CHAR.SUBSTR(qyear,6,1),F1),NUMBER(CHAR.SUBSTR(qyear,1,4),F4)).
EXECUTE.
FORMATS date(QYR8).


-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För Eliassen
Skickat: den 26 juni 2020 10:51
Till: [hidden email]
Ämne: Date formats containing quartils and years

Hello, I am new to SPSS and I am trying to find out how to get the format of date correct. I have quartils and years, exemple : 2007_2, but in the date menu there is no option for this, only q Q yy . What can I do to be able to get the dates correct when I import from excel ?
Thanks!
Best regards,



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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

=====================
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
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Date formats containing quartils and years

Nkem Ntonghanwah
In reply to this post by Eliassen
There are several ways of dealing with your question.
I assume here that the data variable is stored as "STRING" in SPSS.
If so below is one method of dealing with it.

COMPUTE Year=NUMBER(CHAR.SUBSTR(myDate,1,4),F4).
COMPUTE Quater=NUMBER(CHAR.SUBSTR(myDate,6),F2).
FORMATS Year Quater (F4).
EXECUTE.

Best wishes.
Forcheh


On Fri, Jun 26, 2020 at 4:51 AM Eliassen <[hidden email]> wrote:
Hello, I am new to SPSS and I am trying to find out how to get the format of
date correct. I have quartils and years, exemple : 2007_2, but in the date
menu there is no option for this, only q Q yy . What can I do to be able to
get the dates correct when I import from excel ?
Thanks!
Best regards,



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
===================== 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