I am looking to format the post-estimation stored value `e(N)', so it displays with commas.
After running a regression, I make a matrix table from its results and feed them into a personal graphing programme i've made (not on SSC). Functionally, this all works just fine. However, I have an aesthetic issue with how the N from the model is displayed in the note() option of my twoway. If the N is greater than 999 I want it to display with the necessary number of commas. I.e. 1 if inrange(_N , 999 , 999,999) or 2 if inrange(_N , 1,000,000 , 999,999,999), etc. These inrange() things are just pseudo-code to be clear about my request (in practice, I know the commas within the numbers would be problematic).
To demonstrate my problem, this code should do the trick:
Now, I can change format the display directly, as such display %9.0fc `nObs', but I'm so far unable to include a display command in a twoway note() option. The below snippet might make this easier for anyone who can help, Note the output of note()
Best, Chris
After running a regression, I make a matrix table from its results and feed them into a personal graphing programme i've made (not on SSC). Functionally, this all works just fine. However, I have an aesthetic issue with how the N from the model is displayed in the note() option of my twoway. If the N is greater than 999 I want it to display with the necessary number of commas. I.e. 1 if inrange(_N , 999 , 999,999) or 2 if inrange(_N , 1,000,000 , 999,999,999), etc. These inrange() things are just pseudo-code to be clear about my request (in practice, I know the commas within the numbers would be problematic).
To demonstrate my problem, this code should do the trick:
Code:
sysuse auto, clear expand 100 qui regress price foreign, r mat results = r(table) local nObs = `e(N)' di "`nObs'" //There are no commas in the above display. //Below I show my code attempting to format the display of `nObs', and the resulting error messages format "`nObs'" %9.0fc "7400 invalid name r(198); format `nObs' %9.0fc 7400 invalid name r(198);
Code:
twoway (bar price foreign, barw(0.8)), xlab(0 1,valuelabel) ylab(,angle(0)) graphregion(col(white)) note("N = `nObs'")
Best, Chris
Comment