if-command and Date....

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

if-command and Date....

nina
Yesterday I failed with what I considered a simple task - can anybody help me with following problem?
I just wanted to give a new variable scores contingent on the date. So I tried this syntax (numbers are jjust

If date = 01.01.2012 newvar=1.
If date = 02.01.2012 newvar=5.

But surprisingly, this doesn't work. Which syntax could I use instead?

Best,
Nina
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: if-command and Date....

ariel barak
Hi Nina,

Check out the Date Formats section of the Command Syntax Reference.

Try this:

IF date=DATE.MDY(1,1,2012) newvar=1.
IF date=DATE.MDY(2,1,2012) newvar=5.
EXECUTE.

The "MDY" part above tells SPSS the order of the Month, Date, and Year. If your date is in another format, you'll have to change that part.

-Ariel

Virus-free. www.avast.com

On Thu, Jun 1, 2017 at 6:10 AM, nina <[hidden email]> wrote:
Yesterday I failed with what I considered a simple task - can anybody help me
with following problem?
I just wanted to give a new variable scores contingent on the date. So I
tried this syntax (numbers are jjust

If date = 01.01.2012 newvar=1.
If date = 02.01.2012 newvar=5.

But surprisingly, this doesn't work. Which syntax could I use instead?

Best,
Nina




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-and-Date-tp5734304.html
Sent from the SPSSX Discussion mailing list archive at 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SV: if-command and Date....

Robert L
In reply to this post by nina
If your variable date is in a string format rather than actual dates, then I would expect the following to work:

IF date = '01.01.2012' newvar=1

Robert

-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För nina
Skickat: den 1 juni 2017 13:10
Till: [hidden email]
Ämne: if-command and Date....

Yesterday I failed with what I considered a simple task - can anybody help me with following problem?
I just wanted to give a new variable scores contingent on the date. So I tried this syntax (numbers are jjust

If date = 01.01.2012 newvar=1.
If date = 02.01.2012 newvar=5.

But surprisingly, this doesn't work. Which syntax could I use instead?

Best,
Nina




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-and-Date-tp5734304.html
Sent from the SPSSX Discussion mailing list archive at 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
|  
Report Content as Inappropriate

Re: SV: if-command and Date....

Jon Peck
Date literals need to use one of the date function such as yrmoda
if date = yrmoda(2012,01,01) ...
Given the variety and ambiguity of date values, more structure than something like 01.01.2012 is needed.  Statistics would take that as a badly formed numerical value.

On Thu, Jun 1, 2017 at 6:24 AM, Robert Lundqvist <[hidden email]> wrote:
If your variable date is in a string format rather than actual dates, then I would expect the following to work:

IF date = '01.01.2012' newvar=1

Robert

-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För nina
Skickat: den 1 juni 2017 13:10
Till: [hidden email]
Ämne: if-command and Date....

Yesterday I failed with what I considered a simple task - can anybody help me with following problem?
I just wanted to give a new variable scores contingent on the date. So I tried this syntax (numbers are jjust

If date = 01.01.2012 newvar=1.
If date = 02.01.2012 newvar=5.

But surprisingly, this doesn't work. Which syntax could I use instead?

Best,
Nina




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/if-command-and-Date-tp5734304.html
Sent from the SPSSX Discussion mailing list archive at 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



--
Jon K Peck
[hidden email]

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