![]() ![]() display- is not able to list all of the values of a variable. When you write -display bestAlpha-, without anything referencing a macro, Stata then sees that you also have a variable named bestAlpha. So if you had 0 stored in local macro bestAlpha, -display `bestAlpha'- would cause Stata to print 0 on the next line. It is intended to show messages and macros. By contrast, -display- is not intended for showing the values of variables in the data set. So if variable bestAlpha contains 0 in the first observation and is missing in all others, you will get exactly what you saw. ![]() When you type -list bestAlpha- you are asking Stata to show you all of the values in the data set variable bestAlpha. list- is used to show (all or parts of) the data set. While we're here, let's clear up some confusion you have regarding the -list- and -display- commands. In any case, you cannot specify -xline(bestAlpha, lcolor(blue))- because bestAlpha, without either $ or `', is a variable name, and the first argument of -xline- cannot be a variable: it must be a number. So I would store it in a local macro, and then -xline( `bestAlpha ', lcolor(blue)). But let me also point out that a better programming practice is to use a local macro, because it is safe from interference by other programs and contexts. If you store it in a global macro bestAlpha, then the option to scatter would be -xline( $bestAlpha, lcolor(blue)). In that case, you have to refer to the macro correctly. More generally, if it isn't always going to be 0 but might be some other value, you can indeed store that in a macro-still no need for a variable. ![]() Well, if what you want is a vertical line at 0, why go through the rigmarole of creating a "variable" that in fact contains only the single value 0 in a single observation? Why not just, in the -scatter- command specify the option as -xline(0, lcolor(blue)). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |