****************************************************** ** Syntax producing the USA heritage time use files ** ** BSL-ATUS 2010 created by Evrim Altintas ** ** Centre for Time Use Research, University of ** ** Oxford, Department of Sociology, Manor Road ** ** Oxford OX1 3UQ United Kingdom ** ** Last update, 11 Septembe 2011 ** ****************************************************. *the information needed for the heritage format of *the ATUS data is stored across the various files. *the individual elements are now separately extracted. *note that tu06fwgt replaced by tufinwgt as the weighting *procedure changed in 2006, and the cross-time weight now *needs to be based on the same procedure for all years *as opposed to the different procedure adopted in the earlier *years. GET FILE='C:\evrim\AHTUS\2010\atusresp_2010.sav' /keep tucaseid tuyear tumonth tudidate tudiday tufinwgt. freq tuyear tumonth tudidate tudiday. rename variables (tucaseid tuyear tumonth tudiday = pid year month diaryday). *tudidate must be numeric, not string!. compute cday= tudidate - trunc(tudidate/100)*100. freq cday. sort cases by pid. save outfile='C:\evrim\AHTUS\2010\tempa\datewght.sav' /keep pid diaryday cday month year tufinwgt. *extract sex and age to check weights - also to refine closefamily code. GET FILE='C:\evrim\AHTUS\2010\atusrost_2010.sav'. *select for the diarists only. select if terrp=18 or terrp=19. rename variables (tucaseid teage tesex =pid age sex). freq sex. desc age. sort cases by pid. save outfile='C:\evrim\AHTUS\2010\tempa\dem.sav' /keep pid sex age. GET FILE='C:\evrim\AHTUS\2010\atusrost_2010.sav' /keep TUCASEID TULINENO TEAGE TERRP. freq teage terrp. *There is no missing age or relation. compute u5=0. compute u18=0. *>-1 is not to code missings as child. If teage >-1 and teage <5 u5=1. If teage >-1 and teage <18 u18=1. freq u5 u18. cro teage by u5 u18. rename variables tucaseid=pid. sort cases by pid tulineno. save outfile='C:\evrim\AHTUS\2010\tempa\kidflag.sav' /keep pid tulineno teage u5 u18. ********************************* *make who else present variables* *********************************. GET FILE='C:\evrim\AHTUS\2010\atuswho_2010.sav'. freq tuwhocod. *84 cases of missings. rename variables (tucaseid tuact_n=pid epnum). sort cases by pid tulineno. match files files=* table='C:\evrim\AHTUS\2010\tempa\kidflag.sav' /by pid tulineno. execute. *presence of animals and shop or professional staff only *possible to code from the activity data. compute alone=0. compute infant=0. compute child=0. compute sppart=0. compute clsfam=0. compute hhadult=0. compute cowork=0. compute wellknw=0. compute otherp=0. compute unknwp=0. apply dictionary from 'C:\evrim\AHTUS\schema1.sav'. freq alone to unknwp. If tuwhocod=18 or tuwhocod=19 alone=1. cro tuwhocod by alone. cro tuwhocod by u18 u5. temp. select if tuwhocod<0. freq teage u5 u18. *note that some spouses aged <18 - to avoid confusion with spouse and *a child being present from cases of a spouse aged 16-17 only present, *code the child variables only for cases where the tuwhocod>spouse/partner. If u5=1 and tuwhocod>21 infant=1. If u18=1 and tuwhocod>21 child=1. freq infant child. cro child by infant. cro tuwhocod by child. cro u18 by child. cro u5 by child. *check cases of people aged <18 present but no child code are *all diarists or spouses. temp. select if child=0 and u18=1. freq tuwhocod. if tuwhocod=20 or tuwhocod=21 sppart=1. freq sppart. cro tuwhocod by sppart. *not clear whether some potential close family codes are in *the same household or not. This code is not possible to *create for 1975 (spouse), 1985 or 1992-94. The level of *close family present in 1965-66 is 30% of episodes; and *the level for the main respondent diaries in 1975/76 is *33.9%. This definition yields 40% of time around close *family - much higher - but then time around children is *higher in this survey than in the heritage surveys. *this figure will be somewhat distorted in this file *as people with multiple children around their whole *family will have a row case for each child plus the spouse *or partner for each joint activity - this figure should *amend down when matched to the activity file. if (tuwhocod>19 and tuwhocod<26) or tuwhocod=27 clsfam=1. freq clsfam. If tuwhocod=26 or (tuwhocod>27 and tuwhocod<40) hhadult=1. freq hhadult. *In 2010 tuwhocod (who else present)labels has changed. *55 used to be co-workers/colleagues/clients etc. In 2010 it is decomposed: *Now 59 boss or manager, 60 people whom I supervise, 61 co-workers, *62 customers. If tuwhocod=59 or tuwhocod=60 or tuwhocod=61 or tuwhocod=62 cowork=1. freq cowork. If (tuwhocod>19 and tuwhocod<57) wellknw=1. freq wellknw. If tuwhocod=57 or tuwhocod=58 otherp=1. freq otherp. If trwhona=0 and tuwhocod<0 unknwp=1. freq unknwp. cro tuwhocod by hhadult cowork wellknw otherp unknwp. AGGREGATE /OUTFILE="C:\evrim\AHTUS\2010\tempa\addwho.sav" /BREAK=pid epnum /alone = MAX(alone) /infant = MAX(infant) /child = MAX(child) /sppart = MAX(sppart) /clsfam = MAX(clsfam) /hhadult = MAX(hhadult) /cowork = MAX(cowork) /wellknw = MAX(wellknw) /otherp = MAX(otherp) /unknwp = MAX(unknwp). ******************** *time use variables* ********************. Get file='C:\evrim\AHTUS\2010\atusact_2010.sav' /keep tucaseid tuact_n tustart tustop. sort cases by tucaseid tuact_n. SAVE TRANSLATE OUTFILE='C:\evrim\AHTUS\2010\tempa\startstop.dat' /TYPE=TAB /MAP /REPLACE /FIELDNAMES. *this start and stop time information is recorded as string *fields (in hour minute second format, though the second *field is left blank). The file is saved as ASCII and reopened *breaking up the time fields to concert the time information *to a format consistent with the other heritage files. GET DATA /TYPE = TXT /FILE = 'C:\evrim\AHTUS\2010\tempa\startstop.dat' /DELCASE = LINE /DELIMITERS = "\t:" /ARRANGEMENT = DELIMITED /FIRSTCASE = 2 /IMPORTCASE = ALL /VARIABLES = pid F14.0 epnum F2.0 sthr F2.0 stmin F2.0 stsec F2.0 finhr F2.0 finmin F2.0 finsec F2.0 . CACHE. EXECUTE. sort cases by pid(a) epnum (d). compute clockst= sthr*100 + stmin. freq clockst. *NOTE that ATUS 2003-10 begins the diary day at 4:00. *the clockst variable denotes the clock time when *the activity began - but the variables start and *end are converted to mark the minute position in *the diary for consistency with the previous surveys. Do if sthr>3. compute cst=clockst-400. Else if sthr<4. compute cst=clockst+2000. End if. Do if finhr>3. compute cend= (finhr*100 + finmin)-400. Else if finhr<4. compute cend= (finhr*100 + finmin)+2000. end if. execute. *NOTE also that the end time shows the actual *end time and not the end of the diary day. *While this information is extremely useful, *as it is not available in the heritage surveys, *the end time of the last episode is set to 2400. AGGREGATE /OUTFILE* mode=addvariables /BREAK=pid /maxep = MAX(epnum). compute lastep=0. If epnum=maxep lastep=1. freq lastep. *this confirms the recording of 13260 diaries. if lastep=1 cend=2400. desc cend cst. sort cases by pid(a) epnum(a). Compute start=trunc(cst/100)*60+(cst-(trunc(cst/100))*100). Compute end=trunc(cend/100)*60+(cend-(trunc(cend/100))*100). compute time=end-start. desc start end time. save outfile="C:\evrim\AHTUS\2010\tempa\sstime.sav" /keep pid epnum clockst start end time maxep lastep. *TEST* temp. select if lastep=1. freq end. *should be 1440=# of diaries (in 2010 13260). temp. select if epnum=1. freq start. *all should be 0. *************************** *process the activity file* ***************************. Get file='C:\evrim\AHTUS\2010\atusact_2010.sav'. missing values all (). rename variables (tucaseid tuact_n =pid epnum). compute main=-5. compute sec=0. compute inout=-5. compute eloc=-5. compute mtrav=-5. compute survey=7. compute wave=8. *Wave must be changed every year. *(2010=8, 2009=7, 2008=6, 2007=5, 2006=4, 2005=3, 2004=2 etc). apply dictionary from 'C:\evrim\AHTUS\schema1.sav'. freq survey wave. match files files=* files="C:\evrim\AHTUS\2010\tempa\sstime.sav" /BY pid epnum. execute. match files files=* table='C:\evrim\AHTUS\2010\tempa\datewght.sav' /BY pid. match files files=* files="C:\evrim\AHTUS\2010\tempa\addwho.sav" /by pid epnum. freq actcode tewhere. temp. select if tewhere=-2 or tewhere=-1 or tewhere=89. freq actcode. temp. select if actcode=10101 or actcode=10102 or actcode=10201 or actcode=10199 or actcode=10299 or actcode=10401 or actcode=10499 or actcode=30111 or actcode=30112 or actcode=30503 or actcode=30504 or actcode=40111 or actcode=40112 or actcode=40507 or actcode=40508 or actcode=120202 or actcode=130131 or actcode=500105 or actcode=500106. freq actcode. *all instances of sleep (10101); sleeplessnes (10102); sleeping (nec) (10199) *washing & dressing (10201); grooming nec (10299); personal care (10401); *personal care nec (10499), 500106 (do not remember), and 500105 *(none of your business) have no recorded location. Recode the *location of these activities (except for the do not remember) *as the location where they are before starting the activity (unless *this is travelling) or as the next location unless the next *location is travelling or the end of the diary. sort cases by pid(a) epnum(d). compute nextact=-5. compute nextloc=-5. if pid=lag(pid) nextact=lag(actcode). if pid=lag(pid) nextloc=lag(tewhere). freq nextact nextloc. *there are 13260 diaries (we know this as the frequency *of epnum=1 is 13260) with nextloc and nextact=-5 - these *are the last episodes in the diary day. *In 2005 ATUS travel codes are changed from 17xxxx to 18xxxx. temp. select if nextact=-5. freq lastep. sort cases by pid(a) epnum(a). compute next=-5. Do if lastep=1. compute next=5. Else if nextloc=-1 or nextloc=89. compute next=1. Else if nextact>500000 and ((nextloc>0 and nextloc<12) or nextloc=30 or nextloc=31 or nextloc=32). compute next=3. Else if nextact<180000 and ((nextloc>0 and nextloc<12) or nextloc=30 or nextloc=31 or nextloc=32). compute next=4. Else if ((nextloc>11 and nextloc<30) or nextloc=99 or (nextact>17999 and nextact<500101) or nextact=500103). compute next=2. End if. val lab next 1 next still missing 2 travel next 3 next act missing but next location known 4 next act known and not travel and location known 5 end of diary and missing location. freq next. compute prevact=-5. compute prevloc=-5. if pid=lag(pid) prevact=lag(actcode). if pid=lag(pid) prevloc=lag(tewhere). freq prevact prevloc. *again 13260 cases of previous activity and location=-5. *these are the first episodes. format actcode (f4.0). temp. select if epnum=1. freq prevact. compute prev=-5. Do if epnum=1. compute prev=5. Else if prevloc=-1 or prevloc=89. compute prev=1. Else if prevact>500000 and ((prevloc>0 and prevloc<12) or prevloc=30 or prevloc=31 or prevloc=32). compute prev=3. Else if prevact<180000 and ((prevloc>0 and prevloc<12) or prevloc=30 or prevloc=31 or prevloc=32). compute prev=4. Else if ((prevloc>11 and prevloc<30) or prevloc=99 or (prevact>17999 and prevact<500101) or prevact=500103). compute prev=2. End if. val lab prev 1 previous still missing 2 previous travel 3 previous act missing but previous location known 4 previous act known and not travel and location known 5 start of diary and missing location. freq prev. temp. select if lastep=1 or epnum=1. freq tewhere. *most of the first and last episodes have missing location. compute where=tewhere. compute where2=tewhere. freq where. *where will be used to code location. where2 is used to look at *the transformations to ensure the adjustments work as expected. *before we start, 47495 (18.5% of cases)=-1; 908(0.4% of cases)= 89; 3 cases 99. *Location is missing, activity is sleeping/taking a nap. *impute location as previous/next location. Do if pid=lag(pid) and (actcode=10101 or actcode=10102 or actcode=10201 or actcode=10299 or actcode=10401 or actcode=10499 or actcode=500106) and (prev=3 or prev=4). compute where=prevloc. Else if pid=lag(pid) and (actcode=10101 or actcode=10102 or actcode=10201 or actcode=10299 or actcode=10401 or actcode=10499 or actcode=500106) and (next=3 or next=4). compute where=nextloc. End if. freq where. cro tewhere by where. *19439 (7.6% of cases)=-1; 908 (0.4%)=89. Do if epnum=1. compute eptest=1. Else if epnum=2. compute eptest=2. Else if lastep=1. compute eptest=5. Else if epnum=maxep-1. compute eptest=4. Else. compute eptest=3. End if. val lab eptest 1 1st episode 2 2nd episode 3 middle episode 4 next from last episode 5 last episode. temp. select if where=-1 or where=89. freq eptest. *of those locations which remain missing 61.5% are the first episode; *8.6% 2nd episode; 16.1% last episode; 3.2% penultimate episode, rest *in middle. format lastep to eptest (f4.0). compute prev2=0. if where=-1 prev2=lag(where). if where=-1 and $casenum=1 prev2=-5. freq prev2. sort cases by pid(a) epnum(d). compute next2=0. if where=-1 next2=lag(where). if where=-1 and $casenum=1 next2=-5. freq next2. sort cases by pid(a) epnum(a). *second filling-in iteration - where there have been two slots in *a row with the location missing, fill in the location as the *previous or next location so long as the previous or next location *not travelling. Do if pid=lag(pid) and (where=-1 or where=89) and ((prev2>0 and prev2<12) or prev2=30 or prev2=31 or prev2=32). compute where=prev2. Else if (pid=lag(pid) or epnum=1) and (where=-1 or where=89) and ((next2>0 and next2<12) or next2=30 or next2=31 or next2=32). compute where=next2. End if. freq where. cro where by where2. *now 6248 (2.4% of cases)=-1; 908 (0.4%)=89. repeat the *previous iteration to pick up second and penultimate cases. compute prev2=0. if where=-1 prev2=lag(where). if where=-1 and $casenum=1 prev2=-5. freq prev2. sort cases by pid(a) epnum(d). compute next2=0. if where=-1 next2=lag(where). if where=-1 and $casenum=1 next2=-5. freq next2. sort cases by pid(a) epnum(a). Do if pid=lag(pid) and (where=-1 or where=89) and ((prev2>0 and prev2<12) or prev2=30 or prev2=31 or prev2=32). compute where=prev2. Else if (pid=lag(pid) or epnum=1) and (where=-1 or where=89) and ((next2>0 and next2<12) or next2=30 or next2=31 or next2=32). compute where=next2. End if. freq where. cro where by where2. *now 5193 (2% of cases)=-1; 908 (0.4%)=89. temp. select if where=-1 or where=89. freq eptest. *more now at beginning of diary- 37.9% first episode; 26.9% 2nd *episode; 2.7% last episode; 5.4% penult episode, rest in middle. compute test=0. if lastep=1 and where=-1 test=1. freq test. temp. select if epnum=1 and where=-1. freq next actcode nextact. *these diaries start with location unknown followed by travel *or more missing; about 65% sleep followed by personal care. temp. select if epnum=2 and where=-1. cro prevact by nextact nextloc. *deal with cases of sleep or personal care, followed by personal care *in episode 2, followed by travel. Determine where people end up *after their travel cycle completed. compute mark=0. if epnum=2 and actcode=10201 and prevact<10405 and (nextact>130103 and nextact<190000) mark=1. var lab mark 'marker of sleep then wash then cycle/walk or travel'. compute mark2=0. if lastep=1 and (prevact>180000 and prevact<500000) and where=-1 and actcode<10500 mark2=1. freq mark mark2. compute locs=0. compute locf=0. if epnum=1 locs=where. if lastep=1 locf=where. AGGREGATE /OUTFILE* mode=addvariables /BREAK=pid /pattern1 'starts sleep, wash, travel' = MAX(mark) /pattern2 'ends travel then person care or sleep' = MAX(mark2) /locstart=max(locs) /locend=max(locf). cro pattern1 by locend pattern2. cro pattern2 by locstart. if pattern2=1 and lastep=1 and (where=-1 or where=89) and locstart=1 where=1. if pattern1=1 and epnum=1 and (where=-1 or where=89) and locend=1 where=1. if pattern1=1 and epnum=2 and (where=-1 or where=89) and locend=1 where=1. freq where. *now 2280 cases (0.9%) have location=-1 and 908 (0.4%) location not remembered. *rerun some previous iterations as start and end locations now amended. sort cases by pid(a) epnum(d). compute nextloc=-5. if pid=lag(pid) nextloc=lag(where). sort cases by pid(a) epnum(a). save outfile = "C:\evrim\AHTUS\2010\tempa\tempfile1_1.sav". get file = "C:\evrim\AHTUS\2010\tempa\tempfile1_1.sav". compute next=-5. Do if lastep=1. compute next=5. Else if nextloc=-1 or nextloc=89. compute next=1. Else if nextact>500000 and ((nextloc>0 and nextloc<12) or nextloc=30 or nextloc=31 or nextloc=32). compute next=3. Else if nextact<180000 and ((nextloc>0 and nextloc<12) or nextloc=30 or nextloc=31 or nextloc=32). compute next=4. Else if ((nextloc>11 and nextloc<30) or nextloc=99 or (nextact>17999 and nextact<500101) or nextact=500103). compute next=2. End if. val lab next 1 next still missing 2 travel next 3 next act missing but next location known 4 next act known and not travel and location known 5 end of diary and missing location. freq next. compute prevloc=-5. if pid=lag(pid) prevloc=lag(tewhere). compute prev=-5. Do if epnum=1. compute prev=5. Else if prevloc=-1 or prevloc=89. compute prev=1. Else if prevact>500000 and ((prevloc>0 and prevloc<12) or prevloc=30 or prevloc=31 or prevloc=32). compute prev=3. Else if prevact<180000 and ((prevloc>0 and prevloc<12) or prevloc=30 or prevloc=31 or prevloc=32). compute prev=4. Else if ((prevloc>11 and prevloc<30) or prevloc=99 or (prevact>17999 and prevact<500101) or prevact=500103). compute prev=2. End if. val lab prev 1 previous still missing 2 previous travel 3 previous act missing but previous location known 4 previous act known and not travel and location known 5 start of diary and missing location. freq prev. Do if pid=lag(pid) and (actcode=10101 or actcode=10102 or actcode=10201 or actcode=10299 or actcode=10401 or actcode=10499 or actcode=500106) and (prev=3 or prev=4). compute where=prevloc. Else if pid=lag(pid) and (actcode=10101 or actcode=10102 or actcode=10201 or actcode=10299 or actcode=10401 or actcode=10499 or actcode=500106) and (next=3 or next=4). compute where=nextloc. End if. freq where. cro tewhere by where. *now 2022 cases (0.8%) have location=-1 and 908 (0.4%) location not remembered. compute prev2=0. if where=-1 prev2=lag(where). if where=-1 and $casenum=1 prev2=-5. sort cases by pid(a) epnum(d). compute next2=0. if where=-1 next2=lag(where). if where=-1 and $casenum=1 next2=-5. sort cases by pid(a) epnum(a). Do if pid=lag(pid) and (where=-1 or where=89) and ((prev2>0 and prev2<12) or prev2=30 or prev2=31 or prev2=32). compute where=prev2. Else if (pid=lag(pid) or epnum=1) and (where=-1 or where=89) and ((next2>0 and next2<12) or next2=30 or next2=31 or next2=32). compute where=next2. End if. freq where. cro where by where2. *now 1921 cases (0.7%) have location=-1 and 908 (0.4%) location not remembered. temp. select if where=89. freq eptest. *none of 673 don't remember cases at the end of the diary,1 at the beginning *most in the middle of the diary. temp. select if where=-1. freq eptest. *first and middle episodes now have majority of location not reported during *sleep or personal care. look at sequences around both cases. temp. select if where=89. freq prevact actcode nextact prevloc nextloc. *one common pattern here is travel for child care or adult help(own household & *other household), followed by drop-off or pick up adult/child, followed *by adult help or child care travel. These cases are not at home or at the *workplace, unlikely to be school as school runs are more likely to be *remembered. The AHTUS location codes are less detailed than the ATUS *codes, and the location is going to be away from home and in transit, *so these locations set to other. If where=89 and (prevact>180000 and prevact<190000) and (actcode=30111 or actcode=30112 or actcode=30503 or actcode=30504 or actcode=40111 or actcode=40112 or actcode=40507 or actcode=40508) and (nextact>180000 and nextact<190000) where=11. *also a number of 89 cases during walking - check before and after locations and acts. temp. select if where=89 and actcode=130131. cro prevloc by nextloc. *nearly half of these cases are walks returning to the same place (more home than *elsewhere), or tansition walks between home or other home and elsewhere. Code such *cases as outdoors away from home. Other cases in between forms of transport - and *walking could be inside, but are not at home or specified place, so code these as *other place. do if where=89 and actcode=130131 and ((prevloc>-1 and prevloc<12) or (nextloc>-1 and nextloc<12)). compute where=9. else if where=89 and actcode=130131. compute where=11. end if. freq where. *now 1921 cases (0.7%) have location=-1 and 74 (0.0%)=89 location not remembered. temp. select if where=89. freq prevact actcode nextact prevloc nextloc. *these remaining 74 cases all involve waiting for or dropping off an adult *or child, so set these to other location on same principle as the previous *transformation. If where=89 and (actcode=30111 or actcode=30112 or actcode=30504 or actcode=40112 or actcode=40507) where=11. temp. select if where=-1 and epnum>1 and lastep=0. cro prevloc by nextloc. *two main cases where missing location but not beginning or end of diary day, *strings of missing cases (sleep and personal care) together, and single *personal care breaks in between travel episodes. Deal with former first, *counting the number of cases in these strings. compute test=0. Do if epnum=1 and where=-1. compute test=1. Else if where=-1 and pid=lag(pid). compute test=lag(test)+1. End if. freq test. empinclm *3 cases where there are 4 strings of missings. *Visually examine these cases. *Note: Examine the cases with more than three strings of missings. temp. select if test>3. freq pid. *20100303100161 is a good diary with 38 episodes. *20100908101749 is a good diary with 13 episodes. *20100907100562 is a good diary with 33 episodes. Missings are in between two travels. *we cannot conclude that they took place at respondent's house. *Those 3 diaries are visually examined. *In the first two ones, the activities in all the episodes are sleep or washing/dressing. *where place is missing obviously takes place at respondents' house. *E.g.The resp returns back home watches TV and then goes to bed. *Wakes up and does personal care (at home). *Recode the period after self care as resp.s home. Do if pid=20100303100161 or pid=20100908101749 and where=-1. compute where=1. End if. If where=-1 and (prevloc>-1 and prevloc<12) and (nextloc>-1 and nextloc<12) and prevloc=nextloc where=prevloc. execute. temp. select if test=3. cro epnum by locend. *most strings of three are at start of diary day and day ends at home. temp. select if where=-1 and epnum<4. cro locstart by locend. if where=-1 and epnum<4 and locend=1 where=1. freq where. *now 1112 cases (0.4%) have location=-1. temp. select if where=-1. fre prevact nextact actcode. temp. select if where=-1. desc time. compute test=0. if (actcode=10101 or actcode=10102) and where=-1 test=1. temp. select if test=1. freq epnum lastep. *159(117+42) of these 281 cases where sleep remains in missing location *are the first or last episode of the diary day. Visually look *at cases. compute mark=0. compute mark2=0. compute locs=0. compute locf=0. if epnum=1 locs=where. if lastep=1 locf=where. if where=1 mark=1. if where=3 mark2=3. freq mark2. AGGREGATE /OUTFILE* mode=addvariables /BREAK=pid /anyhome 'any time at own home' = MAX(mark) /anyohome 'any time at another home' = MAX(mark2) /locstart2=max(locs) /locend2=max(locf). temp. select if test=1. freq locstart2 locend2. *where the person starts or ends the day at home and *the location where they are asleep is unknown at the *other end of the diary day, code the sleep to being *at home. if test=1 and epnum=1 and locend2=1 where=1. if test=1 and lastep=1 and locstart2=1 where=1. compute test=0. if (actcode=10101 or actcode=10102) and where=-1 test=1. if test=1 and epnum=1 and locend2=3 where=3. if test=1 and lastep=1 and locstart2=3 where=3. compute test=0. if (actcode=10101 or actcode=10102) and where=-1 test=1. temp. select if test=1. cro anyhome by anyohome. temp. select if test=1. desc time. compute test2=0. if time<61 and test=1 test2=1. freq test2. *naps visually examined. *if the person spends any time at home, assume these sleep and nap *episodes are at home. If no time spent at home but time spent at *someone else's home, then the sleeping location set to other home. if anyhome=1 and test=1 where=1. if anyhome=0 and anyohome=3 and test=1 where=3. freq where. *now 822 cases (0.3%) have location=-1. compute test=0. if (actcode=10101 or actcode=10102) and where=-1 test=1. freq test. *now only 46 cases of sleep with unidentified location. visually examine. *these diaries either clearly involve sleep at an other location *or give no clear indication. Code these as at other locations. compute atoth=0. if where=9 or where=11 atoth=1. AGGREGATE /OUTFILE* mode=addvariables /BREAK=pid /anyother 'any time at other location' = MAX(atoth) /nolocslp 'any sleep with no time at home or other home' = MAX(test). temp. select if test=1. cro anyother by nolocslp. if where=-1 and anyother=1 where=11. freq where. *now 323 cases (0.1%) have location=-1. temp. select if where=-1. fre prevact nextact actcode. temp. select if where=-1. desc time. *visually examine the cases where sleep is missing place. temp. select if test=1. freq pid. *save data before filtering out other cases. select if pid=20100112091255 or pid=20100112091949 or pid=20100201102337 or pid=20100302100651 or pid=20100302101470 or pid=20100302101711 or pid=20100302102143 or pid=20100303100785 or pid=20100303100828 or pid=20100303101887 or pid=20100402101809 or pid=20100403101222 or pid=20100403101625 or pid=20100403101721 or pid=20100403101941 or pid=20100604101624 or pid=20100604101786 or pid=20100605100754 or pid=20100605102417 or pid=20100707100919 or pid=20100707102479 or pid=20100806102304 or pid=20100807102405 or pid=20100907100673 or pid=20100907101742 or pid=20100908101832 or pid=20100908101888 or pid=20101009100919 or pid=20101009101347 or pid=20101009102004 or pid=20101009102144 or pid=20101109100708 or pid=20101109102231 or pid=20101110101679 or pid=20101110102528 or pid=20101111101559 or pid=20101210102143 or pid=20101211100584 or pid=20101211101074 or pid=20101211101561. execute. sort cases by pid. AGGREGATE /OUTFILE* mode=addvariables /BREAK=pid /aggtest = MAX(test). sort cases by aggtest pid epnum. *most of the remainder between travel gaps, remainder left missing. *now that the location information filled in wherever possible, *make AHTUS variables. ***************** *AHTUS variables* *****************. *this coding syntax has a hierarchy - coded as outside if possible *first, and if not possible to code as outside, then if possible *to code as in transit, and if not possible, then to code as inside. *cases with unknown location that are most likely to take place inside *sleep and personal care, and those sports that are generally inside, *USA bowling, billiards, gymnastics, martial arts, set to inside, *main activity not possible to code but location is walking set to outside; *and residual set to -8. *see what people are doing when walking (need to avoid coding mall walking *as outside). temp. select if tewhere=14. freq actcode. save outfile= 'C:\evrim\AHTUS\2010\tempa\tempfile2.sav'. get file= 'C:\evrim\AHTUS\2010\tempa\tempfile2.sav'. ******* *inout* *******. compute inout=-5. freq inout. Do if where~=18 and where~=19 and (where=9 or where=17 or actcode=20401 or actcode=20402 or actcode=20499 or actcode=20501 or actcode=20502 or actcode=20599 or actcode=70102 or actcode=40502 or actcode=40105 or actcode=130102 or actcode=130104 or actcode=130106 or actcode=130108 or actcode=130110 or actcode=130112 or actcode=130113 or actcode=130114 or actcode=130116 or actcode=130118 or actcode=130121 or actcode=130123 or actcode=130124 or actcode=130126 or actcode=130127 or actcode=130129 or (where=14 and (actcode=30103 or actcode=30105 or actcode= 30112 or actcode=30199 or actcode=40109 or actcode=40401 or actcode=40199 or actcode=500103 or actcode=500104 or (actcode>180100 and actcode<500101)))). compute inout=1. Else if where<12 or (where>29 and where<89). compute inout=2. Else if where=12 or where=13 or where=15 or where=16 or where=18 or where=19 or where=20 or where=21 or where=99 or (actcode=30103 or actcode=40507 or actcode=110203 or actcode=150202 or (actcode>180100 and actcode<500101) or actcode=30112 or actcode=30503 or actcode=40112). compute inout=3. Else if actcode=20101 or actcode=20301 or actcode=20399 or actcode=20104 or actcode=150302 or actcode<200000 or actcode=130219 or actcode=130215 or actcode=130207 or actcode=130205 or actcode=130119 or actcode=130115 or actcode=130107 or actcode=130105. compute inout=2. Else if where=14. compute inout=1. Else. compute inout=-8. End if. freq inout. cro tewhere where by inout. temp. select if inout=3 and tewhere=14. freq pid. *If true this gives warning. If not, examine the cases where *the respondent was recorded as walking in a vehicle. *20100403101732,20100504101514 and 20101110100630 are walking to pick up/drop off a child.. *Code them as outside. If pid=20100403101732 and where=14 and inout=3 inout=1. If pid=20100504101514 and where=14 and inout=3 inout=1. If pid=20101110100630 and where=14 and inout=3 inout=1. temp. select if inout=1. freq actcode tewhere. temp. select if inout=2. freq actcode tewhere. temp. select if inout=3. freq actcode tewhere. ****** *eloc* ******. Do if where=1. compute eloc=1. Else if where=3. compute eloc=2. Else if where=2. compute eloc=3. Else if where=8. compute eloc=4. Else if where=6 or where=7 or where=10 or where=30 or where=31 or where=32. compute eloc=5. Else if where=4. compute eloc=6. Else if where=5. compute eloc=7. Else if (where>11 and where<22) or (actcode>179999 and actcode<=189999). compute eloc=8. Else if where=9 or where=11. compute eloc=9. Else. compute eloc=-8. End if. freq eloc. cro where by eloc. cro eloc by inout. temp. select if eloc=8 and inout=2. freq actcode where. *205 of those cases are coded as walking (where=14) though actcode is not walking, code them as outside. *The rest is travelling, so code them as inout=3. If eloc=8 and inout=2 and where=14 inout=1. If eloc=8 and inout=2 and where=11 inout=3. temp. select if eloc=-8. freq actcode. ******* *mtrav* *******. Do if where=12 or where=13 or where=19. compute mtrav=1. Else if where=15 or where=16 or where=18 or where=20. compute mtrav=2. Else if where=14 or actcode=130131. compute mtrav=3. Else if where=17 or actcode=130104. compute mtrav=4. Else if where=21 or inout=3 or eloc=8. compute mtrav=5. Else. compute mtrav=-7. End if. freq mtrav. cro eloc by mtrav. cro tewhere by mtrav. cro mtrav by inout. *************************** *mtrav and inout checklist* ***************************. * (1) most cases of mtrav=3(walk) should be inout=1(outside). * (2) mtrav=3(walking) should never be inout=3 (in vehicle). * (3) all mtrav=1(in car) should be inout=3(in vehicle). * (4) vast majority of cycling must be inout=1(outside). * (5) mtrav=5(travel by unknown means) should be inout=3(in a vehicle, almost all of it will be in a vehicle). temp. select if mtrav=3 or mtrav=4. freq actcode. temp. select if mtrav=5. freq actcode. **corect inconsistencies**. *In 4 cases mtrav=1 (car) but inout=1 (outside) instead of inout=3. temp. select if mtrav=1 and inout=1. freq actcode. *1 boating 3 vehicle touring. *Code as inout=3. if mtrav=1 and inout=1 inout=3. temp. select if mtrav=3 and inout=3. freq actcode where. *Will give warning if correct. if mtrav=5 and inout=1 inout=3. cro mtrav by inout. cro eloc by mtrav. temp. select if mtrav= -7 and eloc=9 and (actcode>179999 and actcode<=189999). freq actcode tewhere. *If everything is fine this gives a warning. temp. select if eloc=-8. freq inout mtrav actcode. *Four cases where the diarist is in a vwhicle (inout=3) and mtrav=5 should be eloc=8. If eloc=-8 and inout=3 eloc=8. ******* *child* *******. freq actcode. Do If child=0 and (actcode=30101 or actcode=30102 or actcode=30103 or actcode=30104 or actcode=30105 or actcode=30106 or actcode=30107 or actcode=30109 or actcode=30112 or actcode=30199 or actcode=30201 or actcode=30203 or actcode=30299 or actcode=30301 or actcode=30302 or actcode=30399 or actcode=40101 or actcode=40102 or actcode=40103 or actcode=40104 or actcode=40105 or actcode=40106 or actcode=40107 or actcode=40109 or actcode=40112 or actcode=40199 or actcode=40201 or actcode=40203 or actcode=40299 or actcode=40301 or actcode=40302 or actcode=40399). compute child=1. End if. freq child. ******** *animal* ********. compute animal=0. If actcode=20601 or actcode=20699 or actcode=80701 or actcode=80702 or actcode=90301 or actcode=130110 or actcode=130121 animal=1. freq animal. ********* *shoprof* *********. Compute shoprof=0. If actcode=30202 or actcode=80201 or actcode=80202 or actcode=80301 or actcode=80401 or actcode=80402 or actcode=80501 or actcode=80601 or actcode=80701 or actcode=80801 or actcode=80899 or actcode=90101 or actcode=90103 or actcode=90201 or actcode=90301 or actcode=90401 or actcode=90501 or actcode=100101 or actcode=100102 or actcode=10103 or actcode=100401 or actcode=100499 or (eloc=6 and (actcode=110101 or actcode=110199)) or actcode=110202 or actcode=120401 or actcode=120402 or actcode=120403 or actcode=120404 or actcode=120405 or actcode=130401 or actcode=130402 or actcode=130499 or (eloc>2 and (actcode=70101 or actcode=70103 or actcode=70104 or actcode=70105 or actcode=90102)) shoprof=1. freq shoprof. save outfile="C:\evrim\AHTUS\2010\tempa\tempfile3.sav" /drop test test2. get file ="C:\evrim\AHTUS\2010\tempa\tempfile3.sav". ****** *main* ******. *use this if find a problem in activity code before rerunning code. compute main=-5. freq main. Do if actcode=500105 or actcode=10401 or actcode=10499 or actcode=10599 or actcode=19999. Compute main=1. Else if actcode=10101 or actcode=10102. Compute main=3. Else if actcode=10199. Compute main=5. Else if actcode=10201 or actcode=10299. Compute main=6. Else if actcode=10301 or actcode=10399 or actcode=10501. Compute main=7. Else if actcode=50202. Compute main=8. Else if actcode=110201 or actcode=110203 or actcode=110204 or actcode=119999 or (eloc~=6 and (actcode=110101 or actcode=110199 or actcode=110299)). Compute main=9. Else if tewhere~=1 and (actcode=50101 or actcode=50199 or actcode=50205 or actcode=50299 or actcode=59999). Compute main=10. Else if tewhere=1 and (actcode=50101 or actcode=50199 or actcode=50299 or actcode=59999). Compute main=11. Else if actcode=50102 or actcode=50301 or actcode=50302 or actcode=50303 or actcode=50304 or actcode=50399 or actcode=50305. Compute main=12. Else if actcode=50201 or actcode=50203. Compute main=13. Else if actcode=50103 or actcode=50204 or actcode=50104. Compute main=14. Else if (actcode>50400 and actcode<50406) or actcode=50499 or actcode=180504. Compute main=15. Else if actcode=60101 or actcode=60103 or actcode=60104 or actcode=60199. Compute main=16. Else if actcode=60301 or actcode=60302 or actcode=60303 or actcode=60399. Compute main=17. Else if actcode=60102 or actcode=60299. Compute main=18. Else if actcode=60201 or actcode=60202 or actcode=60203 or actcode=60204 or actcode=60401 or actcode=60402 or actcode=60403 or actcode=60499 or actcode=69999 or actcode=160103. Compute main=19. Else if actcode=20201 or actcode=20202. Compute main=20. Else if actcode=20203 or actcode=20299. Compute main=21. Else if actcode=20101 or actcode=20301 or actcode=20399 or actcode=20401. Compute main=22. Else if actcode=20102 or actcode=20103. Compute main=23. Else if actcode=20302 or actcode=20303 or actcode=20402 or actcode=20499 or actcode=20502 or actcode=20701 or actcode=20799 or actcode=20801 or actcode=20899. Compute main=24. Else if actcode=20104 or actcode=20199 or actcode=20901 or actcode=20902 or actcode=20905 or actcode=20999 or actcode=29999. Compute main=25. Else if actcode=70101 or actcode=70103 or actcode=70104 or actcode=70105 or actcode=90102. Compute main=26. Else if actcode=70102 or actcode=70199 or actcode=70201 or actcode=70299 or actcode=70301 or actcode=70399 or actcode=79999. Compute main=27. Else if actcode=80501 or actcode=80502 or actcode=80599 or actcode=160105. Compute main=28. Else if actcode=80401 or actcode=80402 or actcode=80403 or actcode=80499 or actcode=80701 or actcode=80702 or actcode=80799. Compute main=29. Else if actcode=90101 or actcode=90103 or actcode=90104 or actcode=90199 or actcode=90201 or actcode=90202 or actcode=90299 or actcode=90301 or actcode=90302 or actcode=90399 or actcode=90401 or actcode=90402 or actcode=90499 or actcode=90501 or actcode=90502 or actcode=90599 or actcode=99999 or actcode=160106. Compute main=30. Else if actcode=80201 or actcode=80202 or actcode=80203 or actcode=80299 or actcode=100101 or actcode=100102 or actcode=100103 or actcode=100199 or actcode=100301 or actcode=100302 or actcode=100304 or actcode=100399 or actcode=100401 or actcode=100499 or actcode=109999 or actcode=160108 or actcode=160104. Compute main=31. Else if actcode=80301 or actcode=80302 or actcode=80399 or actcode=80601 or actcode=80602 or actcode=80699 or actcode=80801 or actcode=80899 or actcode=89999. Compute main=32. Else if (infant=1) and (actcode=30101 or actcode=30108 or actcode=30109 or actcode=30199 or actcode=80101 or actcode=80102 or actcode=80199 or actcode=160107). Compute main=33. Else if (child=1 and (actcode=30101 or actcode=30108 or actcode=30109 or actcode=30199 or actcode=80199)) or actcode=80101 or actcode=80102 or actcode=160107 or actcode=80199. Compute main=34. Else if actcode=30108. compute main=34. Else if actcode=30301 or actcode=30302 or actcode=30303 or actcode=30399. Compute main=35. Else if actcode=30103. Compute main=36. Else if actcode=30104 or actcode=30107 or actcode=30201 or actcode=30202 or actcode=30203 or actcode=30204 or actcode=30299. Compute main=37. Else if actcode=30102 or actcode=30106. Compute main=38. Else if actcode=30110 or actcode=30111 or actcode=30112 or actcode=39999. Compute main=39. Else if (actcode>30400 and actcode<30406) or actcode=30499 or (actcode>30500 and actcode<30505) or actcode=30599 or (actcode>40100 and actcode<40105) or (actcode>40105 and actcode<40113) or actcode=40199 or (actcode>40200 and actcode<40205) or actcode=40299 or (actcode>40300 and actcode<40304) or actcode=40399 or (actcode>40400 and actcode<40406) or actcode=40499 or (actcode>40500 and actcode<40509) or actcode=40599 or actcode=49999. Compute main=40. Else if (actcode>150100 and actcode<150107) or actcode=150199 or (actcode>150200 and actcode<150205) or actcode=150299 or actcode=150301 or actcode=150302 or actcode=150399 or actcode=150401 or actcode=150402 or actcode=150499 or actcode=150501 or actcode=150599 or actcode=150601 or actcode=150602 or actcode=150699 or actcode=159999 or actcode=150701 or actcode=150801 or actcode=150799 or actcode=150899. Compute main=41. Else if actcode=100201 or actcode=100299 or actcode=100303 or actcode=100305. Compute main=42. Else if (actcode>140100 and actcode<140106) or actcode=149999. Compute main=49. Else if actcode=120405 or actcode=120499 or actcode=120504. Compute main=50. Else if (actcode>130200 and actcode<130300) or actcode=130302 or actcode=130399 or actcode=130402 or actcode=130499. Compute main=51. Else if actcode=120403. Compute main=52. Else if actcode=120401. Compute main=53. Else if actcode=120402. Compute main=54. Else if actcode=110202 or actcode=110101 or actcode=110199 or actcode=120404 or actcode=110299. Compute main=56. Else if actcode=120201 or actcode=120202 or actcode=120299. Compute main=57. Else if (actcode>130100 and actcode<130104) or actcode=130105 or actcode=130107 or (actcode>130108 and actcode<130112) or (actcode>130112 and actcode<130116) or actcode=130117 or (actcode>130118 and actcode<130131) or (actcode>130131 and actcode<130200) or actcode=130301 or actcode=130401 or actcode=139999. Compute main=60. Else if actcode=130131 or (actcode>500000 and tewhere=14). Compute main=62. Else if actcode=130104. Compute main=63. Else if actcode=130108. Compute main=64. Else if actcode=30105 or actcode=40105. Compute main=65. Else if actcode=130106 or actcode=130112 or actcode=130116 or actcode=130118. Compute main=66. Else if actcode=20501 or actcode=20599. Compute main=67. Else if actcode=20601 or actcode=20602 or actcode=20699. Compute main=68. Else if actcode=120101 or actcode=120199. Compute main=72. Else if actcode=120307 or actcode=129999. Compute main=73. Else if actcode=120313. Compute main=75. Else if actcode=120309. Compute main=76. Else if actcode=120310 or actcode=120311. Compute main=77. Else if actcode=120301 or actcode=120302 or actcode=120399 or actcode=120501 or actcode=120502 or actcode=120503 or actcode=120599. Compute main=78. Else if actcode=120312. Compute main=81. Else if actcode=120306. Compute main=84. Else if actcode=120305. Compute main=85. Else if actcode=120303 or actcode=120304. Compute main=86. Else if actcode=20903. Compute main=87. Else if actcode=160101 or actcode=160102 or actcode=169999 or actcode=160199 or actcode=160201 or actcode=160299. Compute main=88. Else if actcode=20904 or actcode=120308. Compute main=89. Else if actcode=500103. Compute main=90. Else if actcode=180101 or actcode=180199 or (actcode>181100 and actcode< 181200) or actcode=180302 or actcode=180304 or actcode=180305 or (actcode>180400 and actcode<180500). Compute main=91. Else if actcode=180502. Compute main=92. Else if actcode=180501 or actcode=180599 or actcode=180503. Compute main=93. Else if actcode=180601 or actcode=180602 or actcode=180699 or actcode=180603 or actcode=180604. Compute main=94. Else if (actcode>180200 and actcode<180300) or (actcode>180700 and actcode<180800) or (actcode>180800 and actcode<180900) or (actcode>180900 and actcode<181000) or (actcode>181000 and actcode<181100). Compute main=95. Else if actcode=180301 or actcode=180303 or actcode=180399. Compute main=96. Else if (actcode>181400 and actcode<181500) or (actcode>181500 and actcode<181600). Compute main=97. Else if actcode=189999 or (actcode>181200 and actcode<181400) or (actcode>181600 and actcode<181700) or (actcode>181800 and actcode<181900). Compute main=98. Else if actcode=500101 or actcode=500102 or actcode=500104 or actcode=500106 or actcode=500107 or actcode=509999. Compute main=-8. end if. freq main. *any -5 codes will be cases of new codes that were not assigned to *a location. temp. select if main=-5. freq actcode. *if all ok, this will produce a warning that there are no such cases. temp. select if main<15. cro actcode by main. temp. select if main>14 and main<20. cro actcode by main. temp. select if main>19 and main<28. cro actcode by main. temp. select if main>27 and main<35. cro actcode by main. temp. select if main>34 and main<42. cro actcode by main. temp. select if main>41 and main<56. cro actcode by main. temp. select if main>55 and main<62. cro actcode by main. temp. select if main>61 and main<70. cro actcode by main. temp. select if main>69 and main<76. cro actcode by main. temp. select if main>75 and main<84. cro actcode by main. temp. select if main>83 and main<91. cro actcode by main. temp. select if main>90. cro actcode by main. ************************************ *set up variable for quality checks* ************************************. vector dqcheck(3). Loop i=1 to 3. compute dqcheck(i)=0. end loop. var lab dqcheck1 "miss main, mode of transport or in restaurant". var lab dqcheck2 "miss main, 2nd act reported". var lab dqcheck3 "miss 20 min before/after travel". val lab dqcheck1 to dqcheck3 0 ordinary diary 1 includes pattern. freq dqcheck1 to dqcheck3. temp. select if main=-8. freq eloc. Do If main=-8 and eloc=8. compute main=90. compute dqcheck1=1. Else if main=-8 and eloc=6. compute main=56. compute dqcheck1=1. End if. *fill in what secondary activity is possible to identify. If trtcc_ln>0 or trtcocln>0 sec=34. If main<90 and eloc=8 sec=90. freq sec. *If the main activity is missing and the location is *valid and not at home or another home and the *previous location is valid, not travelling, and *different from the present location, the main *activity is coded to impute travel * *if the main activity is valid and not travel and *both the current and previous locations are valid *and the previous location is not travelling and the *current and previous location differ, the secondary *activity is coded as imputed travel * *if the main activity is missing and the location is *at home or another home and the previous location is *travel, main activity is coded as unknown personal *or household care * *if the main activity is missing and the previous location *is travel and the present location is valid but not at *a home, the main activity is coded as imputed out of *home activity. Do if pid=lag(pid). Do if main<0 and ((eloc=1 or eloc=2) and lag(eloc)=8). compute main=2. compute dqcheck3=1. Else if main<0 and ((eloc>2 and eloc<8) or eloc=9) and lag(eloc)=8. compute main=58. Else if main<0 and ((eloc>0 and eloc~=8 and lag(eloc)>0 and lag(eloc)~=8) and eloc~=lag(eloc)). compute main=90. compute dqcheck1=1. Else if (main>0 and main<90) and sec=0 and ( ((eloc>1 and eloc<6) or eloc=7) and ((lag(eloc)>1 and lag(eloc)<6) or lag(eloc)=7)) and eloc~=lag(eloc). compute sec=90. End if. End if. freq sec. temp. select if main=-8 or main=2 or main=58 or main=90. freq main. *if main activity still missing and the location is *valid and not at home, code the main activity as *imputed activity away from home. If main<0 and eloc>2 main=58. temp. select if main=-8 or main=58. freq main. temp. select if main=-8. freq actcode. *214 of the missing activities are coded as unrecorded as *simultaneous activities recorded. investigate where these. temp. select if main=-8 and actcode=500104. freq eloc sec clockst alone child sppart hhadult. *most such cases take place at home or another person's home; *approximately 1/4 of cases overlap a child being in the person's care; *cases spread throughout the day. *check two of the three bad diary tests for these cases, *calculating missing time as not including this simultaneous *activity code. compute misstest=0. if main=-8 and actcode~=500104 misstest=time. AGGREGATE /OUTFILE* mode=addvariables /BREAK=pid /summiss=sum(misstest) /totep=NU(epnum). temp. select if main=-8 and actcode=500104. freq totep summiss. *these diaries have 6 or more activities, and 184 of them *have no or an acceptable amount of missing time. Recode this *activity as imputed personal or household care. if summiss<=90 and main=-8 and actcode=500104 main=2. *now see if any of the remaining missing cases happen at the end of the diary day. compute test=0. if lastep=1 and main=-8 and lag(main)>0 test=1. temp. select if test=1. freq time eloc actcode. *there are 19 such cases at home, 18 of them are own home. compute test2=0. if test=1 test2=lag(main). freq test2. *6 sleep, 7 personal care, 1 meals, *1 TV, 1 receive friends. If test=1 main=4. temp. select if main=-8 or main=2 or main=4 or main=58 or main=90. freq main. *now look at cases where the first activity is missing. compute test=0. If epnum=1 and main=-8 test=1. freq test. temp. select if test=1. freq time eloc. *19 such cases, all at home. compute test2=0. if lag(test)=1 test2=main. freq test2. cro test2 by eloc. *8 asleep, 1 personal care, 1 other meals, 1 food prep, 1 set table *1 walking, 1 walk dgs/pet care, personal care travel, 1 travel rel to consumption, *1 other travel. if test=1 and test2<90 main=4. if time<91 and (test=1 and test2>89) main=2. temp. select if main=-8 or main=2 or main=4 or main=58. freq main. *look at cases that remain missing that happen after sleep. compute test=0. if pid=lag(pid) and main=-8 and (lag(main)=3 or lag(main)=4) test=1. temp. select if test=1. freq eloc time. *148 such cases (146 at own home); those less than an hour *coded as imputed personal or household care. If time<61 and test=1 main=2. temp. select if main=-8 or main=2. freq main. compute test=0. if main=-8 and (lag(main)=9 or lag(main)=20 or lag(main)=21) test=1. temp. select if test=1. freq time eloc. *420 cases where the time gap in a diary follows eating *or food preparation of setting table/putting away *dishes; all at home or another's home. 62% an hour or less, *some gaps very long. Set gaps of an hour or less to *imputed personal or household care. If test=1 and (eloc=1 or eloc=2) and time<61 main=2. temp. select if main=-8 or main=2. freq main. temp. select if actcode>500000. freq main. *at this point, 1481 of the 3707 cases coded with missing codes *in the original data are still coded as missing - 58 now general *personal care; 835 imputed personal or household care, 38 imputed *sleep; 31 restaurant; 628 imputed time away from home; 47 walking; *589 imputed travel. temp. select if main=-8. freq time eloc. *remaining gaps range from 1 minute to 905 minutes. Majority *are 55.1%) an hour or less. No further effort made to fill in gaps *using other diary information. If (main>89 or sec>89) and mtrav=-7 mtrav=5. freq mtrav. *impute eating where no main activity eating but *main activity food preparation or setting table reported. compute eatdr=0. If main=8 or main=9 or main=56 eatdr=time. *check for missing eating time but recorded set table or food prep. AGGREGATE /OUTFILE=* mode=addvariables /BREAK=pid /anyeat = SUM(eatdr). freq anyeat. *at the moment, 8098 (3.1%) no eating. temp. select if anyeat=0. freq maxep main. *some really low episode diaries with missing eating. *There are some diaries with food preparation activities *but no eating. Do if anyeat=0 and (main=20 or main=21) and sec=0 and maxep>9. compute sec=2. End if. freq sec. sort cases by pid epnum. save outfile ='C:\evrim\AHTUS\2010\tempa\tempfile4.sav'. get file ='C:\evrim\AHTUS\2010\tempa\tempfile4.sav'. **hfep is being saved here for the first time** ***********************************************. save outfile='C:\evrim\AHTUS\2010\USA2010hfep.SAV' /KEEP survey wave pid diaryday cday month year time clockst start end epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp tufinwgt. AGGREGATE /OUTFILE='C:\evrim\AHTUS\2010\tempa\USA2010marker.SAV' /BREAK=survey wave pid /dqcheck1=MAX(dqcheck1) /dqcheck2=MAX(dqcheck2) /dqcheck3=MAX(dqcheck3). *extract the state information to construct a separate weight *excluding those states not found in all studies in the AHTUS. match files file='C:\evrim\AHTUS\2010\atusresp_2010.sav' /in=inresp file='C:\evrim\AHTUS\2010\atuscps_2010.sav' /in=incps /keep tucaseid tuyear gestfips prtage. cro incps by inresp. *this leaves just the respondents who completed diaries. The CPS *file includes information on all persons interviewed in the *households and other cases need to be eliminated. sel if inresp=1. execute. fre gestfips. compute state=gestfips. recode state (-9=-9) (1=1) (2=2) (4=3) (5=4) (6=5) (8=6) (9=7) (10=8) (11=9) (12=10) (13=11) (15=12) (16=13) (17=14) (18=15) (19=16) (20=17) (21=18) (22=19) (23=20) (24=21) (25=22) (26=23) (27=24) (28=25) (29=26) (30=27) (31=28) (32=29) (33=30) (34=31) (35=32) (36=33) (37=34) (38=35) (39=36) (40=37) (41=38) (42=39) (44=40) (45=41) (46=42) (47=43) (48=44) (49=45) (50=46) (51=47) (53=48) (54=49) (55=50) (56=51). val lab state -9 data not available 1 ALABAMA 2 ALASKA 3 ARIZONA 4 ARKANSAS 5 CALIFORNIA 6 COLORADO 7 CONNECTICUT 8 DELAWARE 9 DISTRICT OF COLUMBIA 10 FLORIDA 11 GEORGIA 12 HAWAII 13 IDAHO 14 ILLINOIS 15 INDIANA 16 IOWA 17 KANSAS 18 KENTUCKY 19 LOUISIANA 20 MAINE 21 MARYLAND 22 MASSACHUSETTS 23 MICHIGAN 24 MINNESOTA 25 MISSISSIPPI 26 MISSOURI 27 MONTANA 28 NEBRASKA 29 NEVADA 30 NEW HAMPSHIRE 31 NEW JERSEY 32 NEW MEXICO 33 NEW YORK 34 NORTH CAROLINA 35 NORTH DAKOTA 36 OHIO 37 OKLAHOMA 38 OREGON 39 PENNSYLVANIA 40 RHODE ISLAND 41 SOUTH CAROLINA 42 SOUTH DAKOTA 43 TENNESSEE 44 TEXAS 45 UTAH 46 VERMONT 47 VIRGINIA 48 WASHINGTON 49 WEST VIRGINIA 50 WISCONSIN 51 WYOMING. compute exclude=0. if any (state,2,8,12,13,17,27,29,30,32,35,40,46,51) exclude=1. var lab exclude states to exclude in xtimewt. val lab exclude 0 states in all samples 1 states only in most recent samples. cro exclude by state. rename variables (tucaseid = pid). save outfile='C:\evrim\AHTUS\2010\tempa\excludestates.sav' /keep pid exclude. *create variables for summary time use file. Get file='C:\evrim\AHTUS\2010\USA2010hfep.SAV'. freq main. *0.6% of main activity time missing in this file. sort cases by survey pid. Compute t0pcare=0. Compute t1paidw=0. Compute t2ed=0. compute t3unpaid=0. compute t4acvol=0. compute t5outhm=0. compute t6exerc=0. compute t7inhm=0. compute t8media=0. compute t9trav=0. compute tmiss=0. vector tmain(98) tsc(98). compute outside=0. compute inveh=0. compute inside=0. compute locunk=0. compute athome=0. compute atwrksc=0. compute elsewhr=0. compute lunk=0. compute walone=0. compute wchild=0. compute wsppart=0. compute wclsfam=0. compute wother=0. compute withunk=0. If main>-1 and main<10 t0pcare =time. If main>9 and main<16 t1paidw =time. If main>15 and main<20 t2ed =time. If main>19 and main<40 t3unpaid =time. If main>39 and main<50 t4acvol =time. If main>49 and main<60 t5outhm =time. If main>59 and main<70 t6exerc =time. If main>69 and main<80 t7inhm =time. If main>79 and main<90 t8media =time. If main>89 and main<100 t9trav =time. If main=-8 tmiss =time. If inout=1 outside =time. if inout=2 inside =time. if inout=3 inveh =time. if inout=-8 locunk =time. if eloc=1 athome =time. if eloc=3 or eloc=4 atwrksc =time. if eloc=2 or eloc>4 elsewhr =time. If eloc=-8 lunk =time. If alone=1 walone =time. If child=1 wchild =time. If sppart=1 wsppart =time. If clsfam=1 wclsfam =time. If otherp=1 or cowork=1 or shoprof=1 or hhadult=1 or (clsfam=0 and wellknw=1) wother=time. If unknwp=1 withunk =time. Do repeat a=tmain1 to tmain98 /b=tsc1 to tsc98 /i=1 to 98. compute a=0. compute b=0. If main=i a=time. If main=i and (sec>32 and sec<40) b=time. End repeat. execute. apply dictionary from 'C:\evrim\AHTUS\schema2.sav'. desc t0pcare t1paidw t2ed t3unpaid t4acvol t5outhm t6exerc t7inhm t8media t9trav tmiss outside inside inveh locunk athome atwrksc elsewhr lunk walone wchild wsppart wclsfam wother withunk. *compute a test variable to ensure the 1 and 2 digits *sets of time use codes add up to 1440. both cases need *to include missing time in the sum. compute t1dig = SUM(t0pcare to tmiss). compute t2dig = SUM (tmiss to tmain98). execute. save outfile="C:\evrim\AHTUS\2010\tempa\tempfile5.sav". get file ="C:\evrim\AHTUS\2010\tempa\tempfile5.sav". desc tsc1 to tsc98. desc tmain1 to tmain98. *the variables that have no labels do not exist as AHTUS codes *(tmain47, tmain59, tmain61, tmain69, tmain79 and tmain80). *The activities in which no minutes were reported are: *tmain5 tmain43 tmain44 tmain45 tmain46 tmain48 *tmain55 tmain64 tmain70 tmain71 tmain74 tmain82 tmain83 (0=-9). *set all those variable codes which could not be constructed *to -9 for missing. recode tmain5 tsc5 tmain43 tsc43 tmain44 tsc44 tmain45 tsc45 tmain46 tsc46 tmain48 tsc48 tmain55 tsc55 tmain64 tsc64 tmain70 tsc70 tmain71 tsc71 tmain74 tsc74 tmain82 tsc82 tmain83 tsc83 (0=-9). execute. AGGREGATE /OUTFILE='C:\evrim\AHTUS\2010\USA2010hfsum.sav' /BREAK=survey wave pid /diaryday = MAX(diaryday) /cday = MAX(cday) /month = MAX(month) /year = MAX(year) /tottime "total minutes recorded in diary" = SUM(time) /numep 'total original episodes recorded' = MAX(epnum) /t0pcare = SUM(t0pcare) /t1paid = SUM(t1paidw) /t2ed = SUM(t2ed) /t3unpaid = SUM(t3unpaid) /t4acvol = SUM(t4acvol) /t5outhm = SUM(t5outhm) /t6exerc = SUM(t6exerc) /t7inhm = SUM(t7inhm) /t8media = SUM(t8media) /t9trav = SUM(t9trav) /tmiss = SUM(tmiss) /tmain1 = SUM(tmain1) /tmain2 = SUM(tmain2) /tmain3 = SUM(tmain3) /tmain4 = SUM(tmain4) /tmain5 = MAX(tmain5) /tmain6 = SUM(tmain6) /tmain7 = SUM(tmain7) /tmain8 = SUM(tmain8) /tmain9 = SUM(tmain9) /tmain10 = SUM(tmain10) /tmain11 = SUM(tmain11) /tmain12 = SUM(tmain12) /tmain13 = SUM(tmain13) /tmain14 = SUM(tmain14) /tmain15 = SUM(tmain15) /tmain16 = SUM(tmain16) /tmain17 = SUM(tmain17) /tmain18 = SUM(tmain18) /tmain19 = SUM(tmain19) /tmain20 = SUM(tmain20) /tmain21 = SUM(tmain21) /tmain22 = SUM(tmain22) /tmain23 = SUM(tmain23) /tmain24 = SUM(tmain24) /tmain25 = SUM(tmain25) /tmain26 = SUM(tmain26) /tmain27 = SUM(tmain27) /tmain28 = SUM(tmain28) /tmain29 = SUM(tmain29) /tmain30 = SUM(tmain30) /tmain31 = SUM(tmain31) /tmain32 = SUM(tmain32) /tmain33 = SUM(tmain33) /tmain34 = SUM(tmain34) /tmain35 = SUM(tmain35) /tmain36 = SUM(tmain36) /tmain37 = SUM(tmain37) /tmain38 = SUM(tmain38) /tmain39 = SUM(tmain39) /tmain40 = SUM(tmain40) /tmain41 = SUM(tmain41) /tmain42 = SUM(tmain42) /tmain43 = MAX(tmain43) /tmain44 = MAX(tmain44) /tmain45 = MAX(tmain45) /tmain46 = MAX(tmain46) /tmain48 = MAX(tmain48) /tmain49 = SUM(tmain49) /tmain50 = SUM(tmain50) /tmain51 = SUM(tmain51) /tmain52 = SUM(tmain52) /tmain53 = SUM(tmain53) /tmain54 = SUM(tmain54) /tmain55 = MAX(tmain55) /tmain56 = SUM(tmain56) /tmain57 = SUM(tmain57) /tmain58 = SUM(tmain58) /tmain60 = SUM(tmain60) /tmain62 = SUM(tmain62) /tmain63 = SUM(tmain63) /tmain64 = MAX(tmain64) /tmain65 = SUM(tmain65) /tmain66 = SUM(tmain66) /tmain67 = SUM(tmain67) /tmain68 = SUM(tmain68) /tmain70 = MAX(tmain70) /tmain71 = MAX(tmain71) /tmain72 = SUM(tmain72) /tmain73 = SUM(tmain73) /tmain74 = MAX(tmain74) /tmain75 = SUM(tmain75) /tmain76 = SUM(tmain76) /tmain77 = SUM(tmain77) /tmain78 = SUM(tmain78) /tmain81 = SUM(tmain81) /tmain82 = MAX(tmain82) /tmain83 = MAX(tmain83) /tmain84 = SUM(tmain84) /tmain85 = SUM(tmain85) /tmain86 = SUM(tmain86) /tmain87 = SUM(tmain87) /tmain88 = SUM(tmain88) /tmain89 = SUM(tmain89) /tmain90 = SUM(tmain90) /tmain91 = SUM(tmain91) /tmain92 = SUM(tmain92) /tmain93 = SUM(tmain93) /tmain94 = SUM(tmain94) /tmain95 = SUM(tmain95) /tmain96 = SUM(tmain96) /tmain97 = SUM(tmain97) /tmain98 = SUM(tmain98) /tsc1 = SUM(tsc1) /tsc2 = SUM(tsc2) /tsc3 = SUM(tsc3) /tsc4 = SUM(tsc4) /tsc5 = MAX(tsc5) /tsc6 = SUM(tsc6) /tsc7 = SUM(tsc7) /tsc8 = SUM(tsc8) /tsc9 = SUM(tsc9) /tsc10= SUM(tsc10) /tsc11= SUM(tsc11) /tsc12= SUM(tsc12) /tsc13= SUM(tsc13) /tsc14= SUM(tsc14) /tsc15= SUM(tsc15) /tsc16= SUM(tsc16) /tsc17= SUM(tsc17) /tsc18= SUM(tsc18) /tsc19= SUM(tsc19) /tsc20= SUM(tsc20) /tsc21= SUM(tsc21) /tsc22= SUM(tsc22) /tsc23= SUM(tsc23) /tsc24= SUM(tsc24) /tsc25= SUM(tsc25) /tsc26= SUM(tsc26) /tsc27= SUM(tsc27) /tsc28= SUM(tsc28) /tsc29= SUM(tsc29) /tsc30= SUM(tsc30) /tsc31= SUM(tsc31) /tsc32= SUM(tsc32) /tsc33= SUM(tsc33) /tsc34= SUM(tsc34) /tsc35= SUM(tsc35) /tsc36= SUM(tsc36) /tsc37= SUM(tsc37) /tsc38= SUM(tsc38) /tsc39= SUM(tsc39) /tsc40= SUM(tsc40) /tsc41= SUM(tsc41) /tsc42= SUM(tsc42) /tsc43= MAX(tsc43) /tsc44= MAX(tsc44) /tsc45= MAX(tsc45) /tsc46= MAX(tsc46) /tsc48= MAX(tsc48) /tsc49= SUM(tsc49) /tsc50= SUM(tsc50) /tsc51= SUM(tsc51) /tsc52= SUM(tsc52) /tsc53= SUM(tsc53) /tsc54= SUM(tsc54) /tsc55= MAX(tsc55) /tsc56= SUM(tsc56) /tsc57= SUM(tsc57) /tsc58= SUM(tsc58) /tsc60= SUM(tsc60) /tsc62= SUM(tsc62) /tsc63= SUM(tsc63) /tsc64= MAX(tsc64) /tsc65= SUM(tsc65) /tsc66= SUM(tsc66) /tsc67= SUM(tsc67) /tsc68= SUM(tsc68) /tsc70= MAX(tsc70) /tsc71= MAX(tsc71) /tsc72= SUM(tsc72) /tsc73= SUM(tsc73) /tsc74= MAX(tsc74) /tsc75= SUM(tsc75) /tsc76= SUM(tsc76) /tsc77= SUM(tsc77) /tsc78= SUM(tsc78) /tsc81= SUM(tsc81) /tsc82= MAX(tsc82) /tsc83= MAX(tsc83) /tsc84= SUM(tsc84) /tsc85= SUM(tsc85) /tsc86= SUM(tsc86) /tsc87= SUM(tsc87) /tsc88= SUM(tsc88) /tsc89= SUM(tsc89) /tsc90= SUM(tsc90) /tsc91= SUM(tsc91) /tsc92= SUM(tsc92) /tsc93= SUM(tsc93) /tsc94= SUM(tsc94) /tsc95= SUM(tsc95) /tsc96= SUM(tsc96) /tsc97= SUM(tsc97) /tsc98= SUM(tsc98) /outside= SUM(outside) /inside=SUM(inside) /inveh= SUM(inveh) /locunk = SUM(locunk) /athome=SUM(athome) /atwrksc=SUM(atwrksc) /elsewhr= SUM(elsewhr) /lunk = SUM(lunk) /walone = SUM(walone) /wchild = SUM(wchild) /wsppart=SUM(wsppart) /wclsfam= SUM(wclsfam) /wother = SUM(wother) /withunk=SUM(withunk) /t1dig = SUM(t1dig) /t2dig = SUM(t2dig) /tufinwgt=MAX(tufinwgt). ****** *HHID* ******. *extract hhid. in this file, there is a variable called *occurnum labelled unique person identifier which is *not used as only in this file; also there is an *alternative household identifier - qstnum - which *also is not used. The ATUS User Guide identifies *hrhhid as the household id which links back to the *other waves of the CPS data. Get file='C:\evrim\AHTUS\2010\atuscps_2010.sav' /keep tucaseid hrhhid huinttyp. sort cases by tucaseid. match files file=* /in=incps table='C:\evrim\AHTUS\2010\atusresp_2010.sav' /in=inresp /by tucaseid. cro inresp by incps. freq huinttyp. *this selection leaves only lines per CPS interview in households *of respondents who completed diaries, though there will be a line *for each CPS participant where there was more than one in the household. *this step gets rid of the non-time diary element participants. sel if inresp=1. execute. rename variables (tucaseid = pid). sort cases by pid. *at the aggregate statement, the number of cases is *dropped to the number of diarists. *IMPORTANT: CHANGE HRHHID TO NUMERIC. ************************************. AGGREGATE outfile='C:\evrim\AHTUS\2010\tempa\hhid.sav' /BREAK=pid /hhid = MAX(hrhhid). *extract marker of whether household children present. GET FILE='C:\evrim\AHTUS\2010\atusresp_2010.sav' /keep tucaseid trhhchld. rename variables tucaseid=pid. save outfile='C:\evrim\AHTUS\2010\tempa\d.sav'. ****************************************************** *now ready to finalise files, start with summary file* ******************************************************. Get file='C:\evrim\AHTUS\2010\USA2010hfsum.sav'. *check that variables sum to 1440 in aggregated file. formats t0pcare to t2dig (f8.0). execute. freq t1dig t2dig tottime. *all diaries add up to the correct 1440 minutes for *both the 1 and 2 digit levels of activity code. match files files=* files='C:\evrim\AHTUS\2010\tempa\dem.sav' files='C:\evrim\AHTUS\2010\tempa\hhid.sav' files='C:\evrim\AHTUS\2010\tempa\d.sav' /by pid. execute. freq age. *both young and adult diarists. sort cases by hhid pid. save outfile='C:\evrim\AHTUS\2010\tempa\weights.sav'. ********* *badcase* *********. Get file='C:\evrim\AHTUS\2010\USA2010hfep.SAV'. freq main. match files files=* table='C:\evrim\AHTUS\2010\tempa\hhid.sav' /by pid. execute. sort cases by hhid pid. **compute misbasic variable**. compute tmiss2=0. compute aeatdr=0. compute asleep=0. compute apcare=0. compute atrav=0. compute anycare=0. execute. If main=-8 tmiss2=time. desc tmiss2. *include the diaries with food preparation activities *but no eating. If main=8 or main=9 or main=20 or main=21 or main=56 or sec=2 or sec=8 or sec=9 or sec=20 or sec=21 or sec=56 or eloc=6 aeatdr=1. *includes do nothing, think, time out or work break. If main=3 or main=4 or main=5 or main=13 or main=78 or sec=3 or sec=4 or sec=5 or sec=13 or sec=78 asleep=1. *includes purchase of per'l care and imputed p'l or hhold care. If main=1 or main=2 or main=6 or main=7 or main=28 or sec=1 or sec=6 or sec=7 or sec=28 apcare=1. *includes sports/exercise, walking, cycling, outdoor recreation, *gardening, petcare, hunting. If (main>89 and main<99) or main=60 or main=62 or main=63 or main=64 or main=65 or main=66 or main=67 or main=68 or (sec>89 and sec<99) or sec=60 or sec=62 or sec=63 or sec=64 or sec=65 or sec=66 or sec=67 or sec=68 atrav=1. *to create carer flag. If (main>32 and main<41) or (sec>32 and sec<41) anycare=1. execute. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=survey wave hhid pid /eatdr=MAX(aeatdr) /sleep=MAX(asleep) /pcare=MAX(apcare) /trav=MAX(atrav). freq eatdr sleep pcare trav. *compute test variable to figure the diarists who stayed at home all day. compute test=0. if eloc~=lag(eloc) and (hhid=lag(hhid) and pid=lag(pid)) and trav=0 test=1. freq test. compute test2=0. if (hhid=lag(hhid) and pid=lag(pid)) and lag(asleep)=1 and (atrav=1 or (main>9 and main<70) or main>89) and pcare=0 test2=1. freq test2. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=survey wave hhid pid /pcarex=MAX(test2) /travx=MAX(test). if pcare=0 and pcarex=1 pcare=1. if trav=0 and travx=1 trav=1. freq eatdr sleep pcare trav. compute test=0. if eloc=1 or eloc=2 test=time. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=survey wave hhid pid /athome=SUM(test) /maxep=MAX(epnum). desc athome maxep. *Diaries including only 2 of the basic act but have at least *12 episodes where the diarist reports being at home all day *but otherwise meet the other 4 good diary criteria count as *good diaries. if trav=0 and maxep>11 and athome>1000 trav=1. freq trav. AGGREGATE /OUTFILE=* /BREAK=survey wave hhid pid /eatdr=SUM(eatdr) /sleep=SUM(sleep) /pcare=SUM(pcare) /tmiss2=SUM(tmiss2) /trav=SUM(trav) /anycare=MAX(anycare) /epnum=MAX(epnum) /day=MAX(diaryday). compute misbasic=0. execute. If trav=0 misbasic=misbasic+1. If sleep=0 misbasic=misbasic+1. If pcare=0 misbasic=misbasic+1. If eatdr=0 misbasic=misbasic+1. execute. var lab misbasic number basic activites not recorded. freq misbasic. cro anycare by misbasic. *diaries of carers who otherwise meet the 4 good diary criteria count as good diaries. if (epnum>7 or anycare=1) and misbasic=2 misbasic=1. freq misbasic. temp. select if misbasic>1. freq epnum tmiss2. *we need sex and age information. sort cases by hhid pid. match files files= * file="C:\evrim\AHTUS\2010\tempa\usa10sexage_all.sav" file='C:\evrim\AHTUS\2010\tempa\weights.sav' /by hhid pid. execute. compute lowqual=0. execute. if tmiss2>90 or epnum<7 or misbasic>1 lowqual=1. freq lowqual. *696 5.2% bad diaries.-12564 good ones. recode tmiss2 (0 thru 90=0) (91 thru hi=1). recode epnum (0 thru 6=1) (7 thru hi=0) into nep. recode misbasic (0,1=0) (2,3,4=1). execute. freq tmiss2 nep misbasic age sex. *As no sex or age missing, only the diary quality variables *determine bad case in this case. cro tmiss2 by nep by misbasic. *696 bad diaries. 2 diary low quality on all 3 counts. *64 bad on 2 counts. *61 missing basic acts and low episode. *0 missing basic acts and missing 91+ minutes. *3 missing 91+ minutes and low episode. *630 bad on 1 count. *140 have low number of episodes; *449 missing 91+ minutes only; *41 missing 2+ basic acts only. ********** *caremflg* **********. *If the person is missing 2+ basic acts but providing care he/she is flagged as carer. *The person flagged with caremflg is likely to combine one of the basic acts with care. cro anycare by misbasic. compute caremflg=0. if anycare=1 and misbasic=1 and epnum>6 caremflg=1. freq caremflg. cro caremflg by anycare by misbasic. sort cases by hhid pid. save outfile='C:\evrim\AHTUS\2010\tempa\weights2.sav'. get file='C:\evrim\AHTUS\2010\tempa\weights2.sav'. ********* *weights* *********. weight by tufinwgt. freq diaryday. weight off. *tufinwgt corrects for survey and day of the week. compute childm=0. If age<18 childm=1. freq childm. means age by childm /cells= min max. compute origwght = tufinwgt. compute owghtflg = 3. compute xtimewt=0. compute infltwt=0. compute recwght=0. *Note that recwght should sum to the number of diary cases (good and bad) *and its mean should be 1. *Also, the number of cases when you weight by the original inflated weight should be equal *to the the number of cases when you weight by infltwt. apply dictionary from 'C:\evrim\AHTUS\schema2.sav'. compute baddem=0. if sex<1 or age<15 baddem=1. freq lowqual baddem. recode age (15 thru 17=0)(18 thru 24=1)(25 thru 34=2) (35 thru 44=3)(45 thru 54=4)(55 thru 64=5) (65 thru 74=6)(75 thru high=7)(else=8) into agegp. recode age (15 thru 17=0)(18 thru 24=1)(25 thru 34=2) (35 thru 44=3)(45 thru 54=4)(55 thru 64=5) (65 thru 74=6)(75 thru high=7)(else=8) into agegp2. If lowqual=1 or baddem=1 or diaryday=-8 agegp=8. cro agegp by trhhchld. freq agegp agegp2. *need to deflate to sampled number. desc origwght. *the final weight weights up to the population size. *13260 diarists, mean 6659006.059503117, but this weight artificially *increases the child diarists compared to the adults. temp. select if age<18. desc origwght. *the weight for young people is 8658033.521853324. temp. select if age>17. desc origwght. *the weight for adults is 6567403.018598803. Do if age<18. compute origw2=origwght/8658033.521853324. Else if age>17. compute origw2=origwght/6567403.018598803. End if. desc origw2. compute agesexgp=agegp + 10*(sex-1). compute agesex2=agegp2 + 10*(sex-1). freq agesexgp agesex2. recode agesexgp agesex2 (0=1) (10=2) (1=21) (2=22) (3=23) (4=24) (5=25) (6=26) (7=27) (11=31) (12=32) (13=33) (14=34) (15=35) (16=36) (17=37) (8=90) (18=91). val lab agesexgp agesex2 1 "men 15-17" 2 "women 15-17" 21 "men 18-24" 22 "men 25-34" 23 "men 35-44" 24 "men 45-54" 25 "men 55-64" 26 "men 65-74" 27 "men 75+" 31 "women 18-24" 32 "women 25-34" 33 "women 35-44" 34 "women 45-54" 35 "women 55-64" 36 "women 65-74" 37 "women 75+" 90 "men miss age/bad diary" 91 "women miss age/bad diary". missing values agesexgp (90 thru high). cro agesexgp agesex2 by sex. means age by agesexgp agesex2 /cells min max. missing values all (). if agesexgp>89 origw2=0. *The older datasets covered samples of most contiguous states + *Washington DC, but did not draw samples from 11 states: *Delaware, Idaho, Kansas, Montana, Nevada, New Hampshire, *New Mexico, North Dakota, Rhode Island, Vermont, and Wyoming. *The 1992-94, 1995, 1998-1999 and 1999-2001 samples did cover *these states, but did not include Alaska and Hawaii. The ATUS *covers all 50 states. It is possible that with some analysis, *an apparent different across time may reflect the range of *states included. For this reason, we construct two weights *in addition to our recommended weight, one which excludes *the states not covered in the older samples, and a second *which includes all states and inflates to the national population. sort cases by pid. match files files=* file='C:\evrim\AHTUS\2010\tempa\excludestates.sav' /by pid. freq exclude. *6.0% of diarists are states included only in the most recent samples. temp. select if lowqual=0 and exclude=0. freq agesexgp. temp. select if agesexgp<5 and exclude=0. freq agesexgp. temp. select if (agesexgp>5 and agesexgp<90) and exclude=0. freq agesexgp. missing values all (). compute origw3=origw2. if agesexgp>89 or exclude=1 origw3=0. temp. select if agesexgp>89 or exclude=1. desc origw3. temp. select if origw3>0. desc origw3. weight by origw3. fre childm agesexgp. weight off. sort cases by agesexgp diaryday. aggregate outfile='C:\evrim\AHTUS\2010\tempa\group.sav' /break=agesexgp /grouptot=sum(origw2). aggregate outfile='C:\evrim\AHTUS\2010\tempa\day.sav' /break= agesexgp diaryday /daytot=sum(origw2) /dayn=nu. execute. match files file=* /table='C:\evrim\AHTUS\2010\tempa\group.sav' /by agesexgp. execute. match files file=* /table='C:\evrim\AHTUS\2010\tempa\day.sav' /by agesexgp diaryday. execute. sort cases by agesexgp exclude diaryday. aggregate outfile='C:\evrim\AHTUS\2010\tempa\group3.sav' /break=agesexgp exclude /groupt3=sum(origw3). aggregate outfile='C:\evrim\AHTUS\2010\tempa\day3.sav' /break= agesexgp exclude diaryday /daytot3=sum(origw3) /dayn3=nu. execute. match files file=* /table='C:\evrim\AHTUS\2010\tempa\group3.sav' /by agesexgp exclude. execute. match files file=* /table='C:\evrim\AHTUS\2010\tempa\day3.sav' /by agesexgp exclude diaryday. execute. compute exptot=(grouptot/7). compute exptot3=(groupt3/7). Do if lowqual=0 and baddem=0. compute recwght=(exptot/daytot)/(dayn/daytot). End if. Do if lowqual=0 and baddem=0 and exclude=0. compute xtimewt=(exptot3/daytot3)/(dayn3/daytot3). End if. desc recwght xtimewt. compute under18=0. if age<18 under18=1. cro exclude by under18. freq age. *581 child diaries in ALL states in all samples; *12679 adult diaries in ALL states in all samples. *546 child diaries in states in all samples (565-35). *11916 adult diaries in states in all samples (12679-763). compute suma=0. compute sumc=0. if age>17 suma=recwght. if age<18 sumc=recwght. compute xsuma=0. compute xsumc=0. if age>17 xsuma=xtimewt. if age<18 xsumc=xtimewt. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=survey /recadsum = SUM(suma) /recchsum = SUM(sumc) /xadsum = SUM(xsuma) /xchildsum = SUM(xsumc). freq recadsum recchsum xadsum xchildsum. *the sum of adult weights is 12087.5534411513 - it should sum to 12679. *the sum of child weights is 554.426745455403 - it should sum to 581. *the sum of xtime adult weights is 11337.5377434555 - it should sum to 11916. *the sum of xchild weights is 513.90151699558- it should sum to 546. Do if age>17. compute recwght=recwght*(12679/12087.5534411513). Else if age<18. compute recwght=recwght*(581/554.426745455403). End if. desc recwght. *mean is precisely 1. Do if age>17. compute xtimewt=xtimewt*(11916/11337.5377434555). Else if age<18. compute xtimewt=xtimewt*(546/513.90151699558). End if. desc xtimewt. temp. select if exclude=0. desc xtimewt. *mean among the states in all years is 1. weight by recwght. fre diaryday agesexgp. *the age/sex group distribution still matches the *CPS distribution from the original survey weights. cro agesexgp by diaryday /cell=row. cro diaryday by childm. weight off. temp. select if age<18. desc origwght. *the weight for young people is 8658033.521853333. temp. select if age>17. desc origwght. *the weight for adults is 6567403.018598834. *the numbers are means of original weights for adults and children. Do if age<18. compute infltwt=recwght*8658033.521853333. Else if age>17. compute infltwt=recwght*6567403.018598834. End if. desc infltwt. sort cases by survey wave hhid pid. Save outfile='C:\evrim\AHTUS\2010\USA2010youthsum.sav' /drop sleep t1dig t2dig tufinwgt anycare sex age TRHHCHLD misbasic agegp agegp2 origw2 agesexgp agesex2 exclude origw3 grouptot daytot dayn groupt3 daytot3 dayn3 exptot exptot3. sort cases by pid. Save outfile='C:\evrim\AHTUS\2010\tempa\addlow.sav' /keep hhid pid lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght childm. sort cases by survey wave hhid pid. select if childm=0. Save outfile='C:\evrim\AHTUS\2010\USA2010hfsum.sav' /keep survey wave hhid pid diaryday cday month year age tottime numep t0pcare t1paid t2ed t3unpaid t4acvol t5outhm t6exerc t7inhm t8media t9trav tmiss tmain1 tmain2 tmain3 tmain4 tmain5 tmain6 tmain7 tmain8 tmain9 tmain10 tmain11 tmain12 tmain13 tmain14 tmain15 tmain16 tmain17 tmain18 tmain19 tmain20 tmain21 tmain22 tmain23 tmain24 tmain25 tmain26 tmain27 tmain28 tmain29 tmain30 tmain31 tmain32 tmain33 tmain34 tmain35 tmain36 tmain37 tmain38 tmain39 tmain40 tmain41 tmain42 tmain43 tmain44 tmain45 tmain46 tmain48 tmain49 tmain50 tmain51 tmain52 tmain53 tmain54 tmain55 tmain56 tmain57 tmain58 tmain60 tmain62 tmain63 tmain64 tmain65 tmain66 tmain67 tmain68 tmain70 tmain71 tmain72 tmain73 tmain74 tmain75 tmain76 tmain77 tmain78 tmain81 tmain82 tmain83 tmain84 tmain85 tmain86 tmain87 tmain88 tmain89 tmain90 tmain91 tmain92 tmain93 tmain94 tmain95 tmain96 tmain97 tmain98 tsc1 tsc2 tsc3 tsc4 tsc5 tsc6 tsc7 tsc8 tsc9 tsc10 tsc11 tsc12 tsc13 tsc14 tsc15 tsc16 tsc17 tsc18 tsc19 tsc20 tsc21 tsc22 tsc23 tsc24 tsc25 tsc26 tsc27 tsc28 tsc29 tsc30 tsc31 tsc32 tsc33 tsc34 tsc35 tsc36 tsc37 tsc38 tsc39 tsc40 tsc41 tsc42 tsc43 tsc44 tsc45 tsc46 tsc48 tsc49 tsc50 tsc51 tsc52 tsc53 tsc54 tsc55 tsc56 tsc57 tsc58 tsc60 tsc62 tsc63 tsc64 tsc65 tsc66 tsc67 tsc68 tsc70 tsc71 tsc72 tsc73 tsc74 tsc75 tsc76 tsc77 tsc78 tsc81 tsc82 tsc83 tsc84 tsc85 tsc86 tsc87 tsc88 tsc89 tsc90 tsc91 tsc92 tsc93 tsc94 tsc95 tsc96 tsc97 tsc98 outside inveh inside locunk athome atwrksc elsewhr lunk walone wchild wsppart wclsfam wother withunk lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght. Get file='C:\evrim\AHTUS\2010\USA2010hfep.SAV'. freq survey. match files files=* table='C:\evrim\AHTUS\2010\tempa\addlow.sav' /BY pid. execute. apply dictionary from 'C:\evrim\AHTUS\schema1.sav'. freq childm. save outfile='C:\evrim\AHTUS\2010\USA2010hfepA.SAV'. *This has both child and adult files. save outfile='C:\evrim\AHTUS\2010\USA2010youthep.sav'. get file='C:\evrim\AHTUS\2010\USA2010hfepA.SAV'. temp. select if childm=0. SAVE OUTFILE='C:\evrim\AHTUS\2010\USA2010hfep.sav' /keep survey wave hhid pid diaryday cday month year time clockst start end epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght. *Now USA200Xhfep only includes adult files. ****************************************** *check prevalence of secondary activities* ******************************************. compute anysec=0. compute sectime=0. compute secep=0. compute seccc=0. compute seccctm=0. compute secccep=0. Do If sec>0. compute anysec=1. compute sectime= time. compute secep=1. End if. Do If (sec>32 and sec<40) or sec=96 or sec=99. compute seccc=1. compute seccctm= time. compute secccep=1. End if. freq anysec secep seccc secccep. desc sectime seccctm. AGGREGATE /OUTFILE='C:\evrim\AHTUS\2010\tempa\aggr.sav' /BREAK=hhid /anysec 'any secondary activity' = MAX(anysec) /seccc 'any secondary childcare' = MAX(seccc) /sectime 'secondary activity time' = SUM(sectime) /seccctm 'secnodary childcare time' = SUM(seccctm) /secccep '# of secondary childcare episodes' = SUM(secccep) /secep '# of secondary activity episodes' = SUM(secep) /epnum 'number of episodes' = MAX(epnum) /lowqual = MAX(lowqual). Get FILE='C:\evrim\AHTUS\2010\tempa\aggr.sav'. compute propsec= secep/epnum*100. compute pcc= secccep/epnum*100. select if lowqual=0. freq anysec seccc. desc sectime seccctm propsec pcc. temp. select if seccc=1. desc seccctm pcc. ************************************************** *test labels and variables and finalise the files* **************************************************. Get file='C:\evrim\AHTUS\2010\USA2010hfep.SAV'. desc survey wave hhid pid diaryday cday month year time clockst start end epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp lowqual origwght xtimewt infltwt recwght. freq survey wave diaryday cday month year epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp lowqual baddem caremflg. get file='C:\evrim\AHTUS\2010\USA2010hfsum.sav'. desc survey wave hhid pid diaryday cday month year tottime numep t0pcare t1paid t2ed t3unpaid t4acvol t5outhm t6exerc t7inhm t8media t9trav tmiss tmain1 to tsc98 outside inveh inside locunk athome atwrksc elsewhr lunk walone wchild wsppart wclsfam wother withunk origwght xtimewt infltwt recwght. desc tmain1 to tmain90. *this computation must be updated for every survey in accordance with the *unreported activity types (-9s) in that particular survey. compute t=sum(tmiss to tmain4) + sum(tmain6 to tmain42) + sum(tmain49 to tmain54) + sum(tmain56 to tmain63) + sum (tmain65 to tmain68)+ tmain72 + tmain73 + sum(tmain75 to tmain81) + sum(tmain84 to tmain98). freq t. *should total to 1440 minutes for all cases. freq survey wave diaryday cday month year tottime numep lowqual baddem caremflg. temp. select if recwght=0. cro lowqual by baddem. temp. select if recwght~=0. freq diaryday. weight by recwght. freq diaryday. *all days now should be 14.3%. Get file='C:\evrim\AHTUS\2010\USA2010youthsum.sav' /keep survey wave hhid pid diaryday cday month year tottime numep t0pcare t1paid t2ed t3unpaid t4acvol t5outhm t6exerc t7inhm t8media t9trav tmiss tmain1 tmain2 tmain3 tmain4 tmain5 tmain6 tmain7 tmain8 tmain9 tmain10 tmain11 tmain12 tmain13 tmain14 tmain15 tmain16 tmain17 tmain18 tmain19 tmain20 tmain21 tmain22 tmain23 tmain24 tmain25 tmain26 tmain27 tmain28 tmain29 tmain30 tmain31 tmain32 tmain33 tmain34 tmain35 tmain36 tmain37 tmain38 tmain39 tmain40 tmain41 tmain42 tmain43 tmain44 tmain45 tmain46 tmain48 tmain49 tmain50 tmain51 tmain52 tmain53 tmain54 tmain55 tmain56 tmain57 tmain58 tmain60 tmain62 tmain63 tmain64 tmain65 tmain66 tmain67 tmain68 tmain70 tmain71 tmain72 tmain73 tmain74 tmain75 tmain76 tmain77 tmain78 tmain81 tmain82 tmain83 tmain84 tmain85 tmain86 tmain87 tmain88 tmain89 tmain90 tmain91 tmain92 tmain93 tmain94 tmain95 tmain96 tmain97 tmain98 tsc1 tsc2 tsc3 tsc4 tsc5 tsc6 tsc7 tsc8 tsc9 tsc10 tsc11 tsc12 tsc13 tsc14 tsc15 tsc16 tsc17 tsc18 tsc19 tsc20 tsc21 tsc22 tsc23 tsc24 tsc25 tsc26 tsc27 tsc28 tsc29 tsc30 tsc31 tsc32 tsc33 tsc34 tsc35 tsc36 tsc37 tsc38 tsc39 tsc40 tsc41 tsc42 tsc43 tsc44 tsc45 tsc46 tsc48 tsc49 tsc50 tsc51 tsc52 tsc53 tsc54 tsc55 tsc56 tsc57 tsc58 tsc60 tsc62 tsc63 tsc64 tsc65 tsc66 tsc67 tsc68 tsc70 tsc71 tsc72 tsc73 tsc74 tsc75 tsc76 tsc77 tsc78 tsc81 tsc82 tsc83 tsc84 tsc85 tsc86 tsc87 tsc88 tsc89 tsc90 tsc91 tsc92 tsc93 tsc94 tsc95 tsc96 tsc97 tsc98 outside inveh inside locunk athome atwrksc elsewhr lunk walone wchild wsppart wclsfam wother withunk lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght childm. select if childm=1. *this computation must be updated for every survey in accordance with the *unreported activity types (-9s) in that particular survey. compute t=sum(tmiss to tmain4) + sum(tmain6 to tmain42) + sum(tmain49 to tmain54) + sum(tmain56 to tmain63) + sum (tmain65 to tmain68)+ tmain72 + tmain73 + sum(tmain75 to tmain81) + sum(tmain84 to tmain98). freq t. *should total to 1440 minutes for all cases. desc survey wave hhid pid diaryday cday month year tottime numep t0pcare t1paid t2ed t3unpaid t4acvol t5outhm t6exerc t7inhm t8media t9trav tmiss tmain1 to tsc98 outside inveh inside locunk athome atwrksc elsewhr lunk walone wchild wsppart wclsfam wother withunk xtimewt infltwt origwght recwght. freq survey wave diaryday cday month year tottime numep lowqual baddem caremflg. temp. select if recwght=0. cro lowqual by baddem. temp. select if recwght~=0. freq diaryday. weight by recwght. freq diaryday. *all days should be 14.3%. **child summary file**. weight off. apply dictionary from 'C:\evrim\AHTUS\schema1.sav'. sort cases by survey wave hhid pid. Save outfile='C:\evrim\AHTUS\2010\Harmonised files\USA2010youthsum.sav' /drop childm /compressed. Get file='C:\evrim\AHTUS\2010\USA2010youthep.sav' /keep survey wave hhid pid diaryday cday month year time clockst start end epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght childm. select if childm=1. desc survey wave hhid pid diaryday cday month year time clockst start end epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp origwght xtimewt infltwt recwght. freq survey wave diaryday cday month year epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp lowqual baddem caremflg. **child episode file**. weight off. apply dictionary from 'C:\evrim\AHTUS\schema1.sav'. sort cases by survey wave hhid pid. Save outfile='C:\evrim\AHTUS\2010\harmonised Files\USA2010youthep.sav' /drop childm /compressed. ********************************************** *put adult files in 'Harmonised Files' folder* **********************************************. **adult summary file**. get file='C:\evrim\AHTUS\2010\USA2010hfsum.sav'. sort cases by survey wave hhid pid. weight off. apply dictionary from 'C:\evrim\AHTUS\schema2.sav'. sort cases by survey wave hhid pid. Save outfile='C:\evrim\AHTUS\2010\Harmonised files\USA2010hfsum.sav' /keep survey wave hhid pid diaryday cday month year tottime numep t0pcare t1paid t2ed t3unpaid t4acvol t5outhm t6exerc t7inhm t8media t9trav tmiss tmain1 tmain2 tmain3 tmain4 tmain5 tmain6 tmain7 tmain8 tmain9 tmain10 tmain11 tmain12 tmain13 tmain14 tmain15 tmain16 tmain17 tmain18 tmain19 tmain20 tmain21 tmain22 tmain23 tmain24 tmain25 tmain26 tmain27 tmain28 tmain29 tmain30 tmain31 tmain32 tmain33 tmain34 tmain35 tmain36 tmain37 tmain38 tmain39 tmain40 tmain41 tmain42 tmain43 tmain44 tmain45 tmain46 tmain48 tmain49 tmain50 tmain51 tmain52 tmain53 tmain54 tmain55 tmain56 tmain57 tmain58 tmain60 tmain62 tmain63 tmain64 tmain65 tmain66 tmain67 tmain68 tmain70 tmain71 tmain72 tmain73 tmain74 tmain75 tmain76 tmain77 tmain78 tmain81 tmain82 tmain83 tmain84 tmain85 tmain86 tmain87 tmain88 tmain89 tmain90 tmain91 tmain92 tmain93 tmain94 tmain95 tmain96 tmain97 tmain98 tsc1 tsc2 tsc3 tsc4 tsc5 tsc6 tsc7 tsc8 tsc9 tsc10 tsc11 tsc12 tsc13 tsc14 tsc15 tsc16 tsc17 tsc18 tsc19 tsc20 tsc21 tsc22 tsc23 tsc24 tsc25 tsc26 tsc27 tsc28 tsc29 tsc30 tsc31 tsc32 tsc33 tsc34 tsc35 tsc36 tsc37 tsc38 tsc39 tsc40 tsc41 tsc42 tsc43 tsc44 tsc45 tsc46 tsc48 tsc49 tsc50 tsc51 tsc52 tsc53 tsc54 tsc55 tsc56 tsc57 tsc58 tsc60 tsc62 tsc63 tsc64 tsc65 tsc66 tsc67 tsc68 tsc70 tsc71 tsc72 tsc73 tsc74 tsc75 tsc76 tsc77 tsc78 tsc81 tsc82 tsc83 tsc84 tsc85 tsc86 tsc87 tsc88 tsc89 tsc90 tsc91 tsc92 tsc93 tsc94 tsc95 tsc96 tsc97 tsc98 outside inveh inside locunk athome atwrksc elsewhr lunk walone wchild wsppart wclsfam wother withunk lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght. **adult episode file**. get file='C:\evrim\AHTUS\2010\USA2010hfep.sav'. weight off. sort cases by survey wave hhid pid. apply dictionary from 'C:\evrim\AHTUS\schema1.sav'. Save outfile='C:\evrim\AHTUS\2010\Harmonised files\USA2010hfep.sav' /keep survey wave hhid pid diaryday cday month year time clockst start end epnum main sec inout eloc mtrav alone infant child sppart clsfam hhadult animal shoprof cowork wellknw otherp unknwp lowqual baddem caremflg origwght owghtflg xtimewt infltwt recwght. ************************************************** **The end of the syntax producing ** **the USA heritage time use files BSL-ATUS 2010 ** **************************************************.