Hello everyone,
As the title suggests, I've noticed that the week IDs aren't matching the date variable correctly. Specifically:
All comments are appreciated.
Below is the data along with the code and related figures.


As the title suggests, I've noticed that the week IDs aren't matching the date variable correctly. Specifically:
- My goal is to create a unique variable that identifies a week (from a variable containing transaction date information) accurately and consistently.
- From the variable date formatted as %td, I create a variable w containing the week ID (=1 for 1960w1, =2 for 1960w2, ...) and a variable dow containing the IDs of the days of the week (=1 for Monday, =6 for Saturday, and =0 for Sunday).
- At the end of the data, the values of w and dow match in the sense that days of the same week will have the same value of w (as in figure 1). But this is no longer true at the beginning of the data (and seemingly in the middle as well) as in figure 2.
All comments are appreciated.
Below is the data along with the code and related figures.
Code:
. import excel "Bitcoin ", sheet(Sheet2) first case(lower) clear
(3 vars, 4,999 obs)
. desc
Contains data
Observations: 4,999
Variables: 3
-----------------------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------------
date int %td.. date
price str8 %9s price
btc double %10.0g btc
-----------------------------------------------------------------------------------------------
Sorted by:
Note: Dataset has changed since last saved.
. gen w = wofd(date)
. gen dow = dow(date)

Comment