Hi there,

I am running Stata/SE 16.0 and my data looks like this:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int VAcategory float daynumber
1 1
1 1
1 1
3 1
2 1
2 1
2 1
2 1
1 1
2 1
3 1
2 1
1 1
1 1
1 1
1 1
3 1
3 1
3 1
3 1
3 1
2 1
2 1
2 1
2 1
2 1
2 1
1 1
3 1
2 1
2 1
3 1
1 1
1 1
1 1
2 1
2 1
3 1
3 1
2 1
2 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 1
3 1
3 1
2 1
2 1
2 1
2 1
3 1
1 1
2 1
3 1
3 1
3 1
2 1
3 1
2 1
2 1
2 1
2 1
2 1
3 1
2 1
4 1
4 1
3 1
3 1
3 1
3 1
2 1
2 1
3 1
2 1
2 1
2 1
2 1
3 1
2 1
2 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
2 1
2 1
2 1
3 1
3 1
2 1
end
label values VAcategory category
label def category 1 "sedentary", modify
label def category 2 "light", modify
label def category 3 "moderate", modify
label def category 4 "vigorous", modify
I am running the following code and receive an invalid name error as per below:
Code:
. putexcel set test

. count if VAcategory==1 & daynumber==1
  3,742

. putexcel A1 = 'r(N)'
'r invalid name
r(198);
My code is extremely close to an example using the count function provided on page 117 of the Stata Reporting Reference Manual Release 16.

Can anyone assist me with this error? Is it because of the variable types in my dataset? Other putexcel commands are working (e.g.
Code:
putexcel B1 = "test"
). Thanks for your assistance, Sarah