I am trying to extract the quarter from a date variable that looks like dat in the following example:
clear all
input str20 str
"12Jan1998"
"29Dec2000"
end
gen dat = date(str, "DMY")
format dat %tdDD-NN-CCYY
I am trying to use the quarter() function, like in:
gen quart = quarter(dofq(dat))
What I get is clearly wrong. Can you please suggest a way to solve this? According to the example, what I would like to get in the end is 1 and 4.