I haven’t messed with date variables much before, but am now needing to create a simple date variable in format dd.mmm.yy hh:mm (or as close as possible) and then assign values to that variable (both tasks with syntax rather than through direct entry). I’m finding it difficult to find info on this on the web or figure it out on my own although it should be simple. I don’t need to do any manipulations/calculations with it (if that matters). I just need something like… Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc. Do if (ID = 3). Compute/assign (whatever) Testdate = 08.Jan.19 05:30 . End if. I’m likely overlooking something simple. Thanks in advance. Jeff |
Administrator
|
* Create a dataset.
DATA LIST LIST / junk(F1). BEGIN DATA 1 END DATA. * Notice the DATE.DMY and TIME.HMS functions on the next line. COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0). FORMATS Testdate(DATETIME25). LIST. OUTPUT: junk Testdate 1 08-JAN-2019 05:30:00 Jeff-2 wrote > I haven't messed with date variables much before, but am now needing to > create a simple date variable in format dd.mmm.yy hh:mm (or as close as > possible) and then assign values to that variable (both tasks with syntax > rather than through direct entry). > > > > I'm finding it difficult to find info on this on the web or figure it out > on > my own although it should be simple. I don't need to do any > manipulations/calculations with it (if that matters). > > > > I just need something like. > > > > Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc. > > > > Do if (ID = 3). > > Compute/assign (whatever) Testdate = 08.Jan.19 05:30 . > > End if. > > > > I'm likely overlooking something simple. > > > > Thanks in advance. > > > > Jeff > > > > > > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- 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
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by Jeff A
David and Bruce's info was great help and works, but I'm looking everywhere
for documentation on the date formats that both used and can't find what I need. E.g., David mentioned FORMATS MyDateToday (DATETIME17) and Bruce mentioned FORMATS Testdate(DATETIME25). I'm trying to format for dd-mmm-yy hh:mm rather than dd-mmm-yyyy hh:mm and can do this in variable-view of the data editor, but can find no useful documentation anywhere on the web or command syntax reference that lists the various DATETIME formats so that I can know the various data formats to do this formatting with syntax. These don't seem to correspond to the widths or columns listed in the variable view area and my experimentation is coming up with mostly error messages. Where can I find info about this? ...or perhaps there's simply something I don't understand properly. Best, Jeff -----Original Message----- From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce Weaver Sent: Saturday, 12 January 2019 1:01 AM To: [hidden email] Subject: **JUNK** Re: assigning dates to a date variable with syntax * Create a dataset. DATA LIST LIST / junk(F1). BEGIN DATA 1 END DATA. * Notice the DATE.DMY and TIME.HMS functions on the next line. COMPUTE Testdate = DATE.DMY(8,1,2019) + TIME.HMS(5,30,0). FORMATS Testdate(DATETIME25). LIST. OUTPUT: junk Testdate 1 08-JAN-2019 05:30:00 Jeff-2 wrote > I haven't messed with date variables much before, but am now needing > to create a simple date variable in format dd.mmm.yy hh:mm (or as > close as > possible) and then assign values to that variable (both tasks with > syntax rather than through direct entry). > > > > I'm finding it difficult to find info on this on the web or figure it > out on my own although it should be simple. I don't need to do any > manipulations/calculations with it (if that matters). > > > > I just need something like. > > > > Date TestDate (d, dd.mmm.yy. hh:mm) . etc., etc. > > > > Do if (ID = 3). > > Compute/assign (whatever) Testdate = 08.Jan.19 05:30 . > > End if. > > > > I'm likely overlooking something simple. > > > > Thanks in advance. > > > > Jeff > > > > > > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- 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 |
On Fri, Jan 11, 2019 at 4:46 PM Jeff <[hidden email]> wrote: David and Bruce's info was great help and works, but I'm looking everywhere |
In reply to this post by Jeff A
All the variable formats are listed in the CSR under Universals > Variable Types and Formats and Date and Time Formats in particular. However, I don't think you can get two digit years with datetime formats. You can convert a datetime value to a string with that format using a bit of programmability. I can show you that if it would be useful. On Fri, Jan 11, 2019 at 3:46 PM Jeff <[hidden email]> wrote: David and Bruce's info was great help and works, but I'm looking everywhere |
The columns field applies only to the Data Editor and is generally useless. It can be useful, though, if you have a long string but want to show only part of it in the DE view or want to save display space for a numeric value. This is strictly a Data Editor display property. The width field is slightly more useful as it limits the display width of the value in output, but in pivot tables, the width isn't usually important. Of course for strings, the width determines the number of bytes the variable can hold. It has no effect on the internal value of numeric variables as they always take 64 bits (double precision floating point). However, the formats generally triage the value to fit the designated width squeezing out characters in the display like the thousands-delimiting comma or trailing decimals but doesn't affect the internal value. You can see this especially with date formats. On Fri, Jan 11, 2019 at 4:55 PM Jeff <[hidden email]> wrote:
|
Got it. …figured it was something simple. …read right past the distinction between Data and DateTime formats in the CSR. Thanks. Jeff From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck You are pretty close, but you started with Date and ended with DateTime. DateTime has a minimum width of 17, but Date has a minimum of 9. So at the end you should specify DATE9, not DATETIME9. None of those format changes affects the actual values - just the display. On Fri, Jan 11, 2019 at 5:48 PM Jeff <[hidden email]> wrote:
-- Jon K Peck ===================== 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 |
Free forum by Nabble | Edit this page |