|
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 |
|
Hi Nina, Check out the Date Formats section of the Command Syntax Reference.Try this: 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 |
|
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
|
|
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: |
| Free forum by Nabble | Edit this page |
