Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to generate the lagged month local?

    I'm working with the data sets which are 1 month lag. For example, it's now May, but today the data provider sends a data set whose name is like this "data_202304.csv"

    I'm trying to automate the data importing step but don't know how to get the lagged month. If it's the current month, say, the file name is "data_202305.csv" then I can do:

    Code:
    local current_month : di %tdN daily("$S_DATE", "DMY")
    import delimited "path\data_2023`current_month'.csv", clear
    How can I get around this issue?

  • #2
    Code:
    local lagged_month: display %tmCCYYNN mofd(daily("`c(current_date)'", "DMY"))-1

    Comment

    Working...
    X