Hi Statalist, I am new here but this forum is been helpful several times.

I am using stata15, and there's my problem:

I have a large amount of datasets, and I am looping them in order to produce kdensities and compare them. Each dataset has a different sample size.
I am entering the following command inside my loop:

kdensity variable, generate(x y) n() nograph

I am trying to find a way to put automatically the sample size inside the option n().

If I write:

count
kdensity variable, generate(x y) n(r(N)) nograph

stata says: option n() not allowed r(198);
It happens the same if I try to use a local with r(N)

How can I do? I would avoid to make them one-by-one