Announcement

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

  • Converting Stata numeric date tp string

    hi
    Please help me, iam a very new STATA user without much experience

    i have a stata variable cc_3mthsreviewdate, which is a float date variable. So iam trying to do the following

    gen due_for_3mthreview= cc_3mthsreviewdate<c(current_date)

    but when i run the last command in STATA i get a type mismatch ERROR and i figured the reason is because my variable cc_3mthsreviewdat is float and the other one iam comparing against c(current_date) is string
    i have tried all i can to convert cc_3mthsreviewdate so that its string and same format with the other one (c(current_date)) but i have failed , please help me
    I am trying to avoid having to enter manually today's date and i want STATA to pick it up automatically
    Iam happy to post the commands for my do file if it will help , its very short like 10 lines, i didnt post it now to avoid making the post tooo long

  • #2
    Change your line from
    Code:
    gen due_for_3mthreview= cc_3mthsreviewdate<c(current_date)
    to
    Code:
    generate byte due_for_3mthreview = cc_3mthsreviewdate < date("`c(current_date)'", "DMY")
    You can use daily() for the same conversion function.

    Comment

    Working...
    X