Hello everybody,
I'm quite new on Stata and I'm struggling with how to work with data which has %tcDDmonCCYY_HH:MM:SS format.
Below is part of my data that I have: "t" is the date (in %tcDDmonCCYY_HH:MM:SS format), "kwh" is the hourly electricity consumption of a households, and "ni" is the ID of the household.
What I try to do is:
1) To be able to reduce my sample by using tools as "drop" or "keep".
I have already tried some things:
drop if t > mdy(1,1,2016) or
drop if t >= td(01may2013) but it was not working, I think I cannot use these with this format.
Which command should I use ?
2) I also would like to be able to put together these hourly data into weekly data for each of the household.
At the end, I would like to have the electricity consumption per week, per household.
Which command could I use ?
I thank you for your help, and don't hesitate if further details/explanation are needed.
Valentin
I'm quite new on Stata and I'm struggling with how to work with data which has %tcDDmonCCYY_HH:MM:SS format.
Below is part of my data that I have: "t" is the date (in %tcDDmonCCYY_HH:MM:SS format), "kwh" is the hourly electricity consumption of a households, and "ni" is the ID of the household.
What I try to do is:
1) To be able to reduce my sample by using tools as "drop" or "keep".
I have already tried some things:
drop if t > mdy(1,1,2016) or
drop if t >= td(01may2013) but it was not working, I think I cannot use these with this format.
Which command should I use ?
2) I also would like to be able to put together these hourly data into weekly data for each of the household.
At the end, I would like to have the electricity consumption per week, per household.
Which command could I use ?
I thank you for your help, and don't hesitate if further details/explanation are needed.
Valentin
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long ni double(t kwh) 13103610 1.6925796e+12 .553 13103610 1.6925832e+12 .267 13103610 1.6925868e+12 .29400000000000004 13103610 1.6925904e+12 .29300000000000004 13103610 1.692594e+12 .262 13103610 1.6925976e+12 .28900000000000003 13103610 1.6926012e+12 .344 13103610 1.6926048e+12 .343 13103610 1.6926084e+12 1.33 13103610 1.692612e+12 .805 13103610 1.6926156e+12 .818 13103610 1.6926192e+12 .6990000000000001 13103610 1.6926228e+12 .326 13103610 1.6926264e+12 .372 13103610 1.69263e+12 .323 13103610 1.6926336e+12 .29200000000000004 13103610 1.6926372e+12 .29700000000000004 13103610 1.6926408e+12 .7810000000000001 13103610 1.6926444e+12 .8620000000000001 13103610 1.692648e+12 .6020000000000001 13103610 1.6926516e+12 .6150000000000001 13103610 1.6926552e+12 .612 13103610 1.6926588e+12 .5980000000000001 13103610 1.6926624e+12 .651 13103610 1.692666e+12 .41600000000000004 13103610 1.6926696e+12 .251 13103610 1.6926732e+12 .259 13103610 1.6926768e+12 .26 13103610 1.6926804e+12 .276 13103610 1.692684e+12 .273 13103610 1.6926876e+12 .322 13103610 1.6926912e+12 1.006 13103610 1.6926948e+12 1.0050000000000001 13103610 1.6926984e+12 .29400000000000004 13103610 1.692702e+12 .504 13103610 1.6927056e+12 1.7469999999999999 13103610 1.6927092e+12 .39299999999999996 13103610 1.6927128e+12 .259 13103610 1.6927164e+12 .28400000000000003 13103610 1.69272e+12 .30000000000000004 13103610 1.6927236e+12 .41300000000000003 13103610 1.6927272e+12 1.163 13103610 1.6927308e+12 1.0100000000000002 13103610 1.6927344e+12 .429 13103610 1.692738e+12 .5970000000000001 13103610 1.6927416e+12 .5790000000000001 13103610 1.6927452e+12 .643 13103610 1.6927488e+12 .635 13103610 1.6927524e+12 .473 13103610 1.692756e+12 .252 13103610 1.6927596e+12 .249 13103610 1.6927632e+12 .276 13103610 1.6927668e+12 .23 13103610 1.6927704e+12 .246 13103610 1.692774e+12 .287 13103610 1.6927776e+12 .263 13103610 1.6927812e+12 .251 13103610 1.6927848e+12 .279 13103610 1.6927884e+12 2.5020000000000002 13103610 1.692792e+12 2.0370000000000004 13103610 1.6927956e+12 .41300000000000003 13103610 1.6927992e+12 .381 13103610 1.6928028e+12 .404 13103610 1.6928064e+12 .372 13103610 1.69281e+12 .4 13103610 1.6928136e+12 .308 13103610 1.6928172e+12 .41700000000000004 13103610 1.6928208e+12 .35400000000000004 13103610 1.6928244e+12 .41500000000000004 13103610 1.692828e+12 .6910000000000001 13103610 1.6928316e+12 .639 13103610 1.6928352e+12 .622 13103610 1.6928388e+12 .6320000000000001 13103610 1.6928424e+12 .56 13103610 1.692846e+12 .361 13103610 1.6928496e+12 .30000000000000004 13103610 1.6928532e+12 .293 13103610 1.6928568e+12 .301 13103610 1.6928604e+12 .374 13103610 1.692864e+12 .384 13103610 1.6928676e+12 1.009 13103610 1.6928712e+12 1.5350000000000001 13103610 1.6928748e+12 .8500000000000001 13103610 1.6928784e+12 1.4020000000000001 13103610 1.692882e+12 .40800000000000003 13103610 1.6928856e+12 .307 13103610 1.6928892e+12 .5810000000000001 13103610 1.6928928e+12 .652 13103610 1.6928964e+12 .6090000000000001 13103610 1.6929e+12 .864 13103610 1.6929036e+12 1.246 13103610 1.6929072e+12 .47000000000000003 13103610 1.6929108e+12 .301 13103610 1.6929144e+12 .281 13103610 1.692918e+12 .308 13103610 1.6929216e+12 .444 13103610 1.6929252e+12 .6060000000000001 13103610 1.6929288e+12 .30700000000000005 13103610 1.6929324e+12 .29600000000000004 13103610 1.692936e+12 .29300000000000004 end format %tc_DDmonCCYY_HH:MM:SS t
Comment