|
Hi all:
I have a variable in a large data set that reflects the date that an assessment was made. I want to convert the date (for which I have the month/day/year) to a variable that reflects whether or not the specific day was a weekday or weekend. Does anyone have any macros or general advice on how to do this in a more automated fashion? Thanks in advance! Scott ***************************** Scott C. Roesch, Ph.D. Associate Professor Department of Psychology San Diego State University 5500 Campanile Drive San Diego, CA 92182-4611 office phone: (619) 594-2652 fax: (619) 594-1332 ***************************** ===================== 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 |
|
Scott,
>>I have a variable in a large data set that reflects the date that an assessment was made. I want to convert the date (for which I have the month/day/year) to a variable that reflects whether or not the specific day was a weekday or weekend. Does anyone have any macros or general advice on how to do this in a more automated fashion? Thanks in advance! Look at the Xdate.weekday function in the universals section of the reference. Gene Maguin ===================== 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 |
|
compute weekend= any(xdate.wkday(my date),1,7).
Art Kendall Social Research Consultants Gene Maguin wrote: > Scott, > > >>> I have a variable in a large data set that reflects the date that an >>> > assessment was made. I want to convert the date (for which I have the > month/day/year) to a variable that reflects whether or not the specific > day was a weekday or weekend. Does anyone have any macros or general > advice on how to do this in a more automated fashion? Thanks in advance! > > Look at the Xdate.weekday function in the universals section of the > reference. > > Gene Maguin > > ===================== > 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
Art Kendall
Social Research Consultants |
|
xdate.wkday returns 2-5 for weekdays, 7 for Saturday, and 1 for Sunday, so...
data list free /datevar (adate10). begin data 12/1/2008 12/2/2008 12/3/2008 12/4/2008 12/5/2008 12/6/2008 12/7/2008 end data. compute weekday=xdate.wkday(datevar) >1 and xdate.wkday(datevar) < 7. value labels weekday 1 'Weekday' 0 'Weekend'. frequencies variables=weekday. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Art Kendall Sent: Tuesday, December 16, 2008 3:31 PM To: [hidden email] Subject: Re: transforming dates compute weekend= any(xdate.wkday(my date),1,7). Art Kendall Social Research Consultants Gene Maguin wrote: > Scott, > > >>> I have a variable in a large data set that reflects the date that an >>> > assessment was made. I want to convert the date (for which I have the > month/day/year) to a variable that reflects whether or not the specific > day was a weekday or weekend. Does anyone have any macros or general > advice on how to do this in a more automated fashion? Thanks in advance! > > Look at the Xdate.weekday function in the universals section of the > reference. > > Gene Maguin > > ===================== > 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 ===================== 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 |
|
In reply to this post by Scott Roesch
Scott:
COMPUTE weekend = XDATE.WKDAY(datevar) GT 1 AND XDATE.WKDAY(datevar) LT 7. XDATE.WKDAY returns a number between 1 and 7 from a date variable (1 = Sunday). --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Scott Roesch Sent: Tuesday, December 16, 2008 2:42 PM To: [hidden email] Subject: transforming dates Hi all: I have a variable in a large data set that reflects the date that an assessment was made. I want to convert the date (for which I have the month/day/year) to a variable that reflects whether or not the specific day was a weekday or weekend. Does anyone have any macros or general advice on how to do this in a more automated fashion? Thanks in advance! Scott ***************************** Scott C. Roesch, Ph.D. Associate Professor Department of Psychology San Diego State University 5500 Campanile Drive San Diego, CA 92182-4611 office phone: (619) 594-2652 fax: (619) 594-1332 ***************************** ===================== 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 |
| Free forum by Nabble | Edit this page |
