I have an ado called groupfunction which made use of python for calculating Gini coefficients since it is much faster. However, I realized recently that it is not loading the python function. I thought it may be that I made a mistake in my code, but it seems to be a different problem. I'm testing with the example code given in the manual. The python function is not recognized in the program, but it is in memory and can be called on its own, see below:
clear all
version 16.1
python:
from sfi import Data, Scalar
def calcsum(varname, touse):
x = Data.get(varname, None, touse)
Scalar.setValue("r(sum)", sum(x))
end
program varsum
version 16.1
syntax varname [if] [in]
marksample touse
python: calcsum("`varlist'", "`touse'")
display as txt " sum of ‘varlist’: " as res r(sum)
end
sysuse auto, clear
noisily capture varsum price
dis _rc
//But function is in memory!!
gen uno =1
python: calcsum("price", "uno")
dis r(sum)
Any help or thoughts you may have on fixing this would be much appreciated. Thanks!
Related Posts with Ado embedded python code not working
Significance levels in StataHello, I have a question on how Stata calculates significance levels. When I get a P-value of 0.00…
install ado filesHello, I am trying to install some ado files which I downloaded from a website in my stata. I read …
Questions for "drop" participants in long data format for repeated mesurements.Hello! I'd like to ask how to drop observations in such follwing dataset. See the pic below for dat…
Generating a variable that tracks the first time 2 IDs appear simultaneouslyHi, I am new to Stata, so I am not very familiar with the codes. I have a dataset with multiple var…
Generate a count variable capturing # of times a value occurs in categorical variablesDear Stata users, I have a panel data set with 14 string variables each of which indicates whether …
Subscribe to:
Post Comments (Atom)
0 Response to Ado embedded python code not working
Post a Comment