Announcement

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

  • A vector argument to sprintf

    Hi
    I've become quite fond of using sprintf.
    And increasingly often I find myself with a vector of arguments I have to split up in a tedious way.

    So far as I can get with my limited ressources the only thing I can do in Stata is:
    Code:
    v = 12,23,31
    sprintf("%f, %f, %f", v[1], v[2], v[3])
    Is there a smart way of doing something like:
    Code:
    sprintf("%f, %f, %f", v)
    Kind regards

    nhb

  • #2
    Maybe you could try mm_matlist() function from the moremata package (author: Benn Jann) , if the purpose is to control the format of your vector or matrix.

    Comment


    • #3
      Hi Christophe
      Thank you.
      A fine suggestion and I will definitely look into it.
      But I also often use string vectors/matrices.
      I admit that I didn't provide a proper example, sorry.
      Is there something similar for string vectors/matrices?
      Kind regards

      nhb

      Comment


      • #4
        ok, I overlooked the string part of your post. Isn't there some inspiration you could get from
        mm_matlist()'s code?

        Comment


        • #5
          Probably
          I'll look into it.
          The documentation says it uses -sprintf-, so maybe I'm lucky.
          Kind regards

          nhb

          Comment

          Working...
          X