Hi list,
maybe a dummy's question, but I'm at a loss to find help in the help screens of SPSS. I created a date from three variables (day, month, year) but I need that date in string format. I can't reformat it and I'm not able to get the contents of this date variable into a string variable created before with "string gedat(a10)". Can anybody help? Mike |
compute gedate = string(numeric_date,date10).
Art Kendall Social Research Consultants Michael Kreißig wrote: >Hi list, > >maybe a dummy's question, but I'm at a loss to find help in the help screens >of SPSS. I created a date from three variables (day, month, year) but I need >that date in string format. I can't reformat it and I'm not able to get the >contents of this date variable into a string variable created before with >"string gedat(a10)". > >Can anybody help? > >Mike > > > >
Art Kendall
Social Research Consultants |
In reply to this post by Michael Krei=?ISO-8859-1?Q?=DFig?=
Data list fixed/day 1-2 month 4-6 year 8-12.
begin data 30 11 2006 1 12 2006 1 1 2007 end data. string an_day (a2) an_month (a3) an_year (a5). compute an_day = string (day,F2). compute an_month = string (month,F3). compute an_year = string (year,F5). string gedat(a10). compute gedat = concat(an_day,an_month,an_year). list gedat. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Michael Kreißig Sent: Wednesday, 29 November 2006 21:14 To: [hidden email] Subject: Date to String Hi list, maybe a dummy's question, but I'm at a loss to find help in the help screens of SPSS. I created a date from three variables (day, month, year) but I need that date in string format. I can't reformat it and I'm not able to get the contents of this date variable into a string variable created before with "string gedat(a10)". Can anybody help? Mike |
In reply to this post by Michael Krei=?ISO-8859-1?Q?=DFig?=
Look at the syntax guide (base.pdf) pages under Universals, COMPUTE, and FORMATS. Page down to the subsections on date formats and numeric/string transformation.
Assuming you used something like: COMPUTE MyDate = DATE.mdy(m,d,y) . you can use FORMATS to change the display format to various formats without changing underlying date value. To make MyDate display as mm/dd/yyyy use: FORMATS MyDate (ADATE10) . If really need an actual string value like "mm/dd/yyyy" for some reason then use something like: STRING StrDate (A10) COMPUTE StrDate=CONCAT(STRING(m,F2.0),'/',STRING(m,F2.0),'/',STRING(m,F2.0)) It gets more complicated if these are not what you meant. Dennis Deck, PhD RMC Research Corporation [hidden email] -----Original Message----- From: Michael Kreißig [mailto:[hidden email]] Sent: Wednesday, November 29, 2006 2:44 AM Subject: Date to String Hi list, maybe a dummy's question, but I'm at a loss to find help in the help screens of SPSS. I created a date from three variables (day, month, year) but I need that date in string format. I can't reformat it and I'm not able to get the contents of this date variable into a string variable created before with "string gedat(a10)". Can anybody help? Mike |
Free forum by Nabble | Edit this page |