Announcement

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

  • PyStata Python variable to stata scalar

    I am trying to find a way load a scalar/macro in Stata 17 with a value in python using PyStata (from python).
    For example suppose we have variable m=10 in python. Is it possible to load value of m into a scalar or macro y in Stata by a python code?
    Last edited by John Williamss; 04 Apr 2022, 21:56.

  • #2
    Code:
    clear*
    python:
    from sfi import Scalar
    m = 10
    m
    Scalar.setValue("m", m)
    end
    scalar list
    See Stata's Python API documentation:
    https://www.stata.com/python/api17/index.html

    Comment


    • #3
      Originally posted by Scott Merryman View Post
      Code:
      clear*
      python:
      from sfi import Scalar
      m = 10
      m
      Scalar.setValue("m", m)
      end
      scalar list
      See Stata's Python API documentation:
      https://www.stata.com/python/api17/index.html
      Thanks!
      Last edited by John Williamss; 07 May 2022, 02:07.

      Comment

      Working...
      X