|
I have a data set with month of interview coded 1 – 12 and date coded 1 – 31. I wish to convert these to a single date in mm/dd or mmm-dd format, but the FM doesn’t appear to list these formats, only yy/mm/dd, dd-mmm-yyyy etc (under DATA LIST). The interviews were all conducted within a single calendar year: there is no year coded, but if necessary I can compute that manually and add it to the format. I can get so far with: compute monthdate = var614*100+var617. formats monthdate (n4). . . but how can I convert monthdate to mmm-dd format? Once I get this sorted, I want to have a look at daily variation in subjective measures in major surveys either side of (mainly catastrophic) events. This will involve calculating a mean or median for each date before plotting. Thanks in advance for syntax suggestions to do this and to add a fixed year. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop |
|
Administrator
|
John,
Look at the DATE.MDY function. I don't believe there to be any 'yearless' DATE formats but I might be wrong and don't have easy access to the FM at the moment.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
Administrator
|
No access to the FM? Any withdrawal symptoms yet, David? ;-)
You can always get access to the latest version of the FM via this site: http://www-01.ibm.com/support/knowledgecenter/ Click sequence: 1. SPSS Statistics 2. Select version 3. Reference > Command Syntax Reference
--
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 John F Hall
data list list /mymonth myday (2f2).
begin data. 1 1 12 31 8 8 8 15 6 6 5 28 end data. compute WholeDate= date.mdy(mymonth,myday,2014). formats wholedate(adate10). list.
Art Kendall
Social Research Consultants |
|
Art
David's suggestion made interesting reading in the FM. Your solution is perfect. I modified your syntax and tested it on my 1975 Quality of Life in Britain survey: compute Date= date.dmy(var617,var614,1975). formats date(adate10). list date /cases 10. . . to get: Date 03/18/1975 03/20/1975 03/20/1975 03/17/1975 03/17/1975 03/18/1975 03/22/1975 03/18/1975 03/17/1975 03/17/1975 This gives me the dates of all the interviews, so I can now obtain the mean values of subjective indicators (e.g. Bradburn Positive Affect score) for each day using: means affpos by date. However I would like to display them as a line graph with the daily means on the Y axis and the date on the X axis. TSPLOT can deal with single values (eg daily blood pressure readings for one person) but doesn't allow for means. With a lot of [offline] help from Andy Wheeler I've been experimenting with GGraph for values of two and three variables where the cases are dates and times of blood pressure readings for one person. Unfortunately the resulting graphs cannot be produced using the GUI. (I'll post these exchanges on Nabble later). My problem now is how to get a chart to display the daily mean value of affpos. Is there a way of extracting them from the table of means and storing them as values for each date? Can the DATE.DMY arguments contain functions instead of numerics? Actually, whilst testing for this mail, I think I have found a partial solution. Graphs >> Legacy dialogs >> Line Simple >> Define GRAPH /LINE(SIMPLE)=MEAN(affpos) BY Date. However: Graphs >> Legacy dialogs >> Line Multiple >> Define . . won't let me put three variables into the Variable box. John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Art Kendall Sent: 23 February 2016 14:38 To: [hidden email] Subject: Re: Dates from separate numeric vars data list list /mymonth myday (2f2). begin data. 1 1 12 31 8 8 8 15 6 6 5 28 end data. compute WholeDate= date.mdy(mymonth,myday,2014). formats wholedate(adate10). list. ----- Art Kendall Social Research Consultants -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Dates-from-separate-numeric-va rs-tp5731584p5731588.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 |
|
Administrator
|
"TSPLOT can deal with single values (eg daily blood pressure readings for one person) but doesn't allow for means." Well John, AGGREGATE the data first then use TSPLOT? Seems AGGREGATE is a vital missing part of your SPSSucation. "as values for each date? Can the DATE.DMY arguments contain functions instead of numerics?" Just try it. COMPUTE D=DATE.DMY(x-10,MOD(y+20,28),2000+16). COMPUTE D=DATE.MDY(TRUNC(SQRT(y**3)/5),blah blah blah).
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
Administrator
|
John,
Does this help to plug some of the holes? " However: Graphs >> Legacy dialogs >> Line Multiple >> Define . . won't let me put three variables into the Variable box...." That's where data restructuring comes in!!! Bone up on your VARSTOCASES!!! -- MATRIX. SAVE UNIFORM(500,1) / OUTFILE * / VARIABLES ID. END MATRIX. NUMERIC DATE (ADATE). COMPUTE ID=TRUNC(($CASENUM+.001)/20). COMPUTE DATE=DATE.MDY(TRUNC(RV.UNIFORM(1,13)) ,TRUNC(RV.UNIFORM(1,30)) ,2015). DO REPEAT Y=Y1 TO Y3. COMPUTE Y=RV.NORMAL(0,1). END REPEAT. DATASET DECLARE agg. AGGREGATE OUTFILE agg / BREAK ID DATE / M_Y1 TO M_Y3=MEAN(Y1 TO Y3). DATASET ACTIVATE agg. VARSTOCASES MAKE M FROM M_Y1 TO M_Y3/INDEX=Varname(M). SPLIT FILE BY ID. DATASET ACTIVATE agg. GRAPH /LINE(MULTIPLE)=MEAN(M) BY DATE BY Varname.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
David
What time is it over there? Don't you ever go to bed? You're right about my experience with AGGREGATE: more or less never. Ditto even more for DATE functions. This old dog still has to learn some new tricks. Don't quite follow your syntax. The number of cases varies within each date. What I want to do is calculate the mean on a dependent variable (affpos) across all cases with the same interview date and then add that as the value of a new variable (affposmean) for each case interviewed on that date. In programming terms I can think of conditional operations using date value of previous case. The cases are not in date order, but I can easily sort them. I'll check out LAG and some universals Given my lack of SPSSucation, it would probably be quicker for me to do this manually by copying means from the [means affpos by date] table and pasting them in blocks into the Data Editor. Testing while I write. Eureka! AGGREGATE /BREAK=date /affposmean=MEAN(affpos). GRAPH /LINE(SIMPLE)=MEAN(affposmean) BY Date. Next step: additional dependent vars and GGRAPH. No stopping me now. John John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 February 2016 10:03 To: [hidden email] Subject: Re: Dates from separate numeric vars John, Does this help to plug some of the holes? " However: Graphs >> Legacy dialogs >> Line Multiple >> Define . . won't let me put three variables into the Variable box...." That's where data restructuring comes in!!! Bone up on your VARSTOCASES!!! -- MATRIX. SAVE UNIFORM(500,1) / OUTFILE * / VARIABLES ID. END MATRIX. NUMERIC DATE (ADATE). COMPUTE ID=TRUNC(($CASENUM+.001)/20). COMPUTE DATE=DATE.MDY(TRUNC(RV.UNIFORM(1,13)) ,TRUNC(RV.UNIFORM(1,30)) ,2015). DO REPEAT Y=Y1 TO Y3. COMPUTE Y=RV.NORMAL(0,1). END REPEAT. DATASET DECLARE agg. AGGREGATE OUTFILE agg / BREAK ID DATE / M_Y1 TO M_Y3=MEAN(Y1 TO Y3). DATASET ACTIVATE agg. VARSTOCASES MAKE M FROM M_Y1 TO M_Y3/INDEX=Varname(M). SPLIT FILE BY ID. DATASET ACTIVATE agg. GRAPH /LINE(MULTIPLE)=MEAN(M) BY DATE BY Varname. David Marso wrote > "TSPLOT can deal with single values (eg daily blood pressure readings > for one > person) but doesn't allow for means." > > Well John, AGGREGATE the data first then use TSPLOT? > Seems AGGREGATE is a vital missing part of your SPSSucation. > > "as values for each date? Can the DATE.DMY arguments contain > functions instead of numerics?" > > Just try it. > COMPUTE D=DATE.DMY(x-10,MOD(y+20,28),2000+16). > COMPUTE D=DATE.MDY(TRUNC(SQRT(y**3)/5),blah blah blah). > > John F Hall wrote >> Art >> >> David's suggestion made interesting reading in the FM. >> >> Your solution is perfect. I modified your syntax and tested it on my >> 1975 >> Quality of Life in Britain survey: >> >> compute Date= date.dmy(var617,var614,1975). >> formats date(adate10). >> list date /cases 10. >> >> . . to get: >> >> Date >> >> 03/18/1975 >> 03/20/1975 >> 03/20/1975 >> 03/17/1975 >> 03/17/1975 >> 03/18/1975 >> 03/22/1975 >> 03/18/1975 >> 03/17/1975 >> 03/17/1975 >> >> This gives me the dates of all the interviews, so I can now obtain >> the mean values of subjective indicators (e.g. Bradburn Positive >> Affect score) for each day using: >> >> means affpos by date. >> >> However I would like to display them as a line graph with the daily >> means on the Y axis and the date on the X axis. >> >> TSPLOT can deal with single values (eg daily blood pressure readings >> for one >> person) but doesn't allow for means. >> >> With a lot of [offline] help from Andy Wheeler I've been >> experimenting with GGraph for values of two and three variables where >> the cases are dates and times of blood pressure readings for one >> person. Unfortunately the resulting graphs cannot be produced using >> the GUI. (I'll post these exchanges on Nabble later). >> >> My problem now is how to get a chart to display the daily mean value >> of affpos. >> Is there a way of extracting them from the table of means and storing >> them as values for each date? Can the DATE.DMY arguments contain >> functions instead of numerics? >> >> Actually, whilst testing for this mail, I think I have found a >> partial solution. >> >> Graphs >> Legacy dialogs >> Line >> Simple >> Define >> >> GRAPH >> /LINE(SIMPLE)=MEAN(affpos) BY Date. >> >> However: >> >> Graphs >> Legacy dialogs >> Line >> Multiple >> Define >> >> . . won't let me put three variables into the Variable box. >> >> John F Hall (Mr) >> [Retired academic survey researcher] >> >> Email: >> johnfhall@ >> >> Website: www.surveyresearch.weebly.com SPSS start page: >> www.surveyresearch.weebly.com/1-survey-analysis-workshop >> >> >> >> >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto: >> SPSSX-L@.UGA >> ] On Behalf Of Art >> Kendall >> Sent: 23 February 2016 14:38 >> To: >> SPSSX-L@.UGA >> Subject: Re: Dates from separate numeric vars >> >> data list list /mymonth myday (2f2). >> begin data. >> 1 1 >> 12 31 >> 8 8 >> 8 15 >> 6 6 >> 5 28 >> end data. >> compute WholeDate= date.mdy(mymonth,myday,2014). >> formats wholedate(adate10). >> list. >> >> >> >> ----- >> Art Kendall >> Social Research Consultants >> -- >> View this message in context: >> http://spssx-discussion.1045642.n5.nabble.com/Dates-from-separate-num >> eric-va >> rs-tp5731584p5731588.html >> Sent from the SPSSX Discussion mailing list archive at Nabble.com. >> >> ===================== >> 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 >> >> ===================== >> 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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Dates-from-separate-numeric-va rs-tp5731584p5731596.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 |
| Free forum by Nabble | Edit this page |
