Announcement

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

  • A question about dofc (the result turns out to be 0)

    Hello all,

    There is a string variable dtlastchangeddate. The specific data look like this:
    Click image for larger version

Name:	_20180712165537.png
Views:	1
Size:	81.4 KB
ID:	1453036



    We want to use docf command on it.
    Then we write code:
    Code:
    encode dtlastchangeddate,gen (date)
    gen r_date=dofc(date)
    However, all values of r_date are 0.
    Click image for larger version

Name:	_20180712170057.png
Views:	1
Size:	6.3 KB
ID:	1453037


    Are there any problems during the process?

    Any advice and guidance would be greatly appreciated! Thanks a lot.

    Li



  • #2
    Yes, there are fatal problems here: encode is quite wrong for dates. You need to push your strings through clock() and then dofc(). No other way to do it (short of writing your own commands) and no other way to learn than to study


    Code:
    help datetime

    Comment


    • #3
      Nick.

      Thanks for your help and the "help".
      That's the first time for me to deal with date variables (excited).
      The last sentence is fabulous. To study and to practice.
      Glad to have you here.


      Comment

      Working...
      X