Neither PROC GLM nor PROC MIXED reports the number of observations, N, in the results produced by the LSMEANS statement. You can use PROC FREQ to obtain N. For example,
proc glm; class a b; model y = a b a*b; lsmeans a b a*b / pdiff; run;
proc freq;
table a b a*b;
where y is not missing and a is not missing and b is not missing;
run;
The WHERE statement is needed when your data has missing values for some of the variables in the model.
For more information on the computation of LSMEANS, see Least-Squares Means in the GLM documentation. In addition, SAS Note 24984 shows how PROC GLM computes LS-means, tests differences of LS-means, and how to save results in a data set. See also the SAS System for Mixed Models and the Milliken & Johnson references (SAS Note 22608).