I want to run python codes on the current variables of Stata using PyStata. For example:

  • set obs 5
  • gen a = _n
  • python
  • a
  • end

But python does not recognize "a". Instead I should run:

  • python
  • a = [1, 2, 3, 4, 5]
  • a
  • end

How can I use the existed "a" instead of new coding?

More Seyyed Amir Yasin Ahmadi's questions See All
Similar questions and discussions