Trying to find the syntax to identify the 1st Monday of the month in a data set of date values over several years. I thought I had seen this before but couldn't find it in the archives, my apologies if I missed it. ===================== 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 |
Please give more detail, perhaps with an example set of data with date and a
flag variable indicating what you would want the result of the suggested syntax to be. Do want the first Monday that occurs *in the data* even if it is the second or third month on a calendar? ----- Art Kendall Social Research Consultants -- 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
Art Kendall
Social Research Consultants |
Thanks Art. Whether a string or a 0,1 binary for the flag, I need to identify among activity dates which is the 1st Monday of any given month. Hope what I have helps, if not just holler.
actv_date = date of activity FMM = indicator of 1st Monday of the month actv_date FMM 6/29/2020 6/30/2020 7/1/2020 7/2/2020 7/3/2020 7/4/2020 7/5/2020 7/6/2020 Y 7/7/2020 7/8/2020 > On July 11, 2020 at 10:44 AM Art Kendall <[hidden email]> wrote: > > > Please give more detail, perhaps with an example set of data with date and a > flag variable indicating what you would want the result of the suggested > syntax to be. > > Do want the first Monday that occurs *in the data* even if it is the second > or third month on a calendar? > > > > ----- > Art Kendall > Social Research Consultants > -- > 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 |
Sorry Art, missed part of your question, I'm only flagging the 1st Monday that occurs in any month, not the 2nd, 3rd or 4th Mondays.
> On July 11, 2020 at 11:37 AM coxspss coxspss <[hidden email]> wrote: > > > Thanks Art. Whether a string or a 0,1 binary for the flag, I need to identify among activity dates which is the 1st Monday of any given month. Hope what I have helps, if not just holler. > > actv_date = date of activity > FMM = indicator of 1st Monday of the month > > actv_date FMM > 6/29/2020 > 6/30/2020 > 7/1/2020 > 7/2/2020 > 7/3/2020 > 7/4/2020 > 7/5/2020 > 7/6/2020 Y > 7/7/2020 > 7/8/2020 > > > > > > On July 11, 2020 at 10:44 AM Art Kendall <[hidden email]> wrote: > > > > > > Please give more detail, perhaps with an example set of data with date and a > > flag variable indicating what you would want the result of the suggested > > syntax to be. > > > > Do want the first Monday that occurs *in the data* even if it is the second > > or third month on a calendar? > > > > > > > > ----- > > Art Kendall > > Social Research Consultants > > -- > > 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 |
Administrator
|
In reply to this post by wsu_wright
As Art K said in his reply, some clarification is needed, and a sample
dataset showing what you want to do would help. But meanwhile, I suspect that you need one of more of the date extraction functions shown here: https://www.ibm.com/support/knowledgecenter/en/SSLVMB_26.0.0/statistics_reference_project_ddita/spss/base/syn_date_and_time_extraction_functions.html See especially: XDATE.YEAR(datevalue) XDATE.MONTH(datevalue) XDATE.WKDAY(datevalue) HTH. coxspss wrote > Trying to find the syntax to identify the 1st Monday of the month in a > data set of date values over several years. I thought I had seen this > before but couldn't find it in the archives, my apologies if I missed it. > > ===================== > 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 wsu_wright
Try this code. data list list/actv_date(adate10). begin data. 6/29/2020 6/30/2020 7/1/2020 7/2/2020 7/3/2020 7/4/2020 7/5/2020 7/6/2020 7/7/2020 7/8/2020 end data compute wkday = xdate.wkday(actv_date). do if wkday eq 2. compute firstmonday = xdate.mday(actv_date) <= 7. else. compute firstmonday = 0. end if. On Sat, Jul 11, 2020 at 9:40 AM coxspss coxspss <[hidden email]> wrote: Sorry Art, missed part of your question, I'm only flagging the 1st Monday that occurs in any month, not the 2nd, 3rd or 4th Mondays. |
Thanks Jon, the code worked perfectly, and thanks to Art & Bruce for having me revise the description. On July 11, 2020 at 12:05 PM Jon Peck <[hidden email]> wrote:===================== 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 |
Administrator
|
Here's a variation on Jon's code that doesn't compute variable wkday. (If
you don't need it for anything else, why have it clutter up your dataset needlessly?) COMPUTE FirstMonday = XDATE.WKDAY(DateVar) EQ 2 AND XDATE.MDAY(DateVar) LE 7. FORMATS FirstMonday(F1). coxspss wrote > Thanks Jon, the code worked perfectly, and thanks to Art & Bruce for > having me revise the description. > >> On July 11, 2020 at 12:05 PM Jon Peck < > jkpeck@ > > wrote: >> >> Try this code. >> data list list/actv_date(adate10). >> begin data. >> 6/29/2020 >> 6/30/2020 >> 7/1/2020 >> 7/2/2020 >> 7/3/2020 >> 7/4/2020 >> 7/5/2020 >> 7/6/2020 >> 7/7/2020 >> 7/8/2020 >> end data >> >> compute wkday = xdate.wkday(actv_date). >> do if wkday eq 2. >> compute firstmonday = xdate.mday(actv_date) <= 7. >> else. >> compute firstmonday = 0. >> end if. >> >> On Sat, Jul 11, 2020 at 9:40 AM coxspss coxspss < > coxspss@ > mailto: > coxspss@ > > wrote: >> >> > > Sorry Art, missed part of your question, I'm only flagging >> the 1st Monday that occurs in any month, not the 2nd, 3rd or 4th Mondays. >> > >> > >> > > On July 11, 2020 at 11:37 AM coxspss coxspss < > coxspss@ > mailto: > coxspss@ > > wrote: >> > > >> > > >> > > Thanks Art. Whether a string or a 0,1 binary for the flag, I >> need to identify among activity dates which is the 1st Monday of any >> given month. Hope what I have helps, if not just holler. >> > > >> > > actv_date = date of activity >> > > FMM = indicator of 1st Monday of the month >> > > >> > > actv_date FMM >> > > 6/29/2020 >> > > 6/30/2020 >> > > 7/1/2020 >> > > 7/2/2020 >> > > 7/3/2020 >> > > 7/4/2020 >> > > 7/5/2020 >> > > 7/6/2020 Y >> > > 7/7/2020 >> > > 7/8/2020 >> > > >> > > >> > > >> > > >> > > > On July 11, 2020 at 10:44 AM Art Kendall < > Art@ > > wrote: >> > > > >> > > > >> > > > Please give more detail, perhaps with an example set of >> data with date and a >> > > > flag variable indicating what you would want the result of >> the suggested >> > > > syntax to be. >> > > > >> > > > Do want the first Monday that occurs *in the data* even if >> it is the second >> > > > or third month on a calendar? >> > > > >> > > > >> > > > >> > > > ----- >> > > > Art Kendall >> > > > Social Research Consultants >> > > > -- >> > > > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ >> > > > >> > > > ===================== >> > > > To manage your subscription to SPSSX-L, send a message to >> > > > > LISTSERV@.UGA > mailto: > 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 >> > >> > ===================== >> > To manage your subscription to SPSSX-L, send a message to >> > > LISTSERV@.UGA > mailto: > 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 >> > >> > > >> >> -- >> Jon K Peck >> > jkpeck@ > mailto: > jkpeck@ >> >> ===================== To manage your subscription to SPSSX-L, send a >> message to > LISTSERV@.UGA > mailto: > 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 >> > > ===================== > 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/). |
I admit, my code was not elegant. I was trying to show the logic by breaking it into pieces, but Bruce’s more concise version is just fine. On Sat, Jul 11, 2020 at 12:00 PM Bruce Weaver <[hidden email]> wrote: Here's a variation on Jon's code that doesn't compute variable wkday. (If |
In reply to this post by Bruce Weaver
Thanks gentlemen, once I saw the codes, the logic became evident of what I was missing, simple and eloquent.
> On July 11, 2020 at 2:00 PM Bruce Weaver <[hidden email]> wrote: > > > Here's a variation on Jon's code that doesn't compute variable wkday. (If > you don't need it for anything else, why have it clutter up your dataset > needlessly?) > > COMPUTE FirstMonday = > XDATE.WKDAY(DateVar) EQ 2 AND > XDATE.MDAY(DateVar) LE 7. > FORMATS FirstMonday(F1). > > > > > coxspss wrote > > Thanks Jon, the code worked perfectly, and thanks to Art & Bruce for > > having me revise the description. > > > >> On July 11, 2020 at 12:05 PM Jon Peck < > > > jkpeck@ > > > > wrote: > >> > >> Try this code. > >> data list list/actv_date(adate10). > >> begin data. > >> 6/29/2020 > >> 6/30/2020 > >> 7/1/2020 > >> 7/2/2020 > >> 7/3/2020 > >> 7/4/2020 > >> 7/5/2020 > >> 7/6/2020 > >> 7/7/2020 > >> 7/8/2020 > >> end data > >> > >> compute wkday = xdate.wkday(actv_date). > >> do if wkday eq 2. > >> compute firstmonday = xdate.mday(actv_date) <= 7. > >> else. > >> compute firstmonday = 0. > >> end if. > >> > >> On Sat, Jul 11, 2020 at 9:40 AM coxspss coxspss < > > > coxspss@ > > > mailto: > > > coxspss@ > > > > wrote: > >> > >> > > Sorry Art, missed part of your question, I'm only flagging > >> the 1st Monday that occurs in any month, not the 2nd, 3rd or 4th Mondays. > >> > > >> > > >> > > On July 11, 2020 at 11:37 AM coxspss coxspss < > > > coxspss@ > > > mailto: > > > coxspss@ > > > > wrote: > >> > > > >> > > > >> > > Thanks Art. Whether a string or a 0,1 binary for the flag, I > >> need to identify among activity dates which is the 1st Monday of any > >> given month. Hope what I have helps, if not just holler. > >> > > > >> > > actv_date = date of activity > >> > > FMM = indicator of 1st Monday of the month > >> > > > >> > > actv_date FMM > >> > > 6/29/2020 > >> > > 6/30/2020 > >> > > 7/1/2020 > >> > > 7/2/2020 > >> > > 7/3/2020 > >> > > 7/4/2020 > >> > > 7/5/2020 > >> > > 7/6/2020 Y > >> > > 7/7/2020 > >> > > 7/8/2020 > >> > > > >> > > > >> > > > >> > > > >> > > > On July 11, 2020 at 10:44 AM Art Kendall < > > > Art@ > > > > wrote: > >> > > > > >> > > > > >> > > > Please give more detail, perhaps with an example set of > >> data with date and a > >> > > > flag variable indicating what you would want the result of > >> the suggested > >> > > > syntax to be. > >> > > > > >> > > > Do want the first Monday that occurs *in the data* even if > >> it is the second > >> > > > or third month on a calendar? > >> > > > > >> > > > > >> > > > > >> > > > ----- > >> > > > Art Kendall > >> > > > Social Research Consultants > >> > > > -- > >> > > > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > >> > > > > >> > > > ===================== > >> > > > To manage your subscription to SPSSX-L, send a message to > >> > > > > > > LISTSERV@.UGA > > > mailto: > > > 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 > >> > > >> > ===================== > >> > To manage your subscription to SPSSX-L, send a message to > >> > > > > LISTSERV@.UGA > > > mailto: > > > 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 > >> > > >> > > > >> > >> -- > >> Jon K Peck > >> > > > jkpeck@ > > > mailto: > > > jkpeck@ > > >> > >> ===================== To manage your subscription to SPSSX-L, send a > >> message to > > > LISTSERV@.UGA > > > mailto: > > > 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 > >> > > > > ===================== > > 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 |
Free forum by Nabble | Edit this page |