Hello everyone,
Let's say I have a timeseries dataset containing number of admissions in a day. However we only track admissions every Monday and Thursday. In order to really utilize time series operator such as lags (L), I need to generate calendar dates (due to the date gaps). I think I did this successfully. However when I use the tin option it does not work. Am I missing something?
This is pnly a subset of my data. the ultimate goal is to generate a line chart(tsline) for only 2018 and compared it with previous years (L12, L24 etc)
Let's say I have a timeseries dataset containing number of admissions in a day. However we only track admissions every Monday and Thursday. In order to really utilize time series operator such as lags (L), I need to generate calendar dates (due to the date gaps). I think I did this successfully. However when I use the tin option it does not work. Am I missing something?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int dt float los 18994 146.97275 18997 143.96909 19001 137.86528 19004 137.9362 19008 139.04283 end format %td dt
Code:
Listed 5 out of 5 observations . bcal create OBCCLOS, from(dt) replace Business calendar OBCCLOS (format %tbOBCCLOS): purpose: range: 02jan2012 16jan2012 18994 19008 in %td units 0 4 in %tbOBCCLOS units center: 02jan2012 18994 in %td units 0 in %tbOBCCLOS units omitted: 10 days 243.5 approx. days/year included: 5 days 121.8 approx. days/year Notes: business calendar file OBCCLOS.stbcal saved . . generate dtcal = bofd("OBCCLOS",dt) . format %tbOBCCLOS dtcal . listsome dt dtcal +-----------------------+ | dt dtcal | |-----------------------| 1. | 02jan2012 02jan2012 | 2. | 05jan2012 05jan2012 | 3. | 09jan2012 09jan2012 | 4. | 12jan2012 12jan2012 | 5. | 16jan2012 16jan2012 | +-----------------------+ . assert dt!=. if dtcal!=. . tsset dtcal time variable: dtcal, 02jan2012 to 16jan2012 delta: 1 day . list los L1.los +---------------------+ | L.| | los los | |---------------------| 1. | 146.9727 . | 2. | 143.9691 146.9727 | 3. | 137.8653 143.9691 | 4. | 137.9362 137.8653 | 5. | 139.0428 137.9362 | +---------------------+ . tsline los L1.los if tin(02jan2012, 09jan2012) invalid syntax
Code:
tsline los L12.los L24.los if tin(01jan2018, 31oct2018)
Comment