Contents: | Purpose / Requirements / Usage / Details / Limitations / References |
%inc "<location of your file containing the SUM_GLM macro>";
Following this statement, you may call the %SUM_GLM macro. See the Results tab for an example.
The input data set, specified in the data= option should be structured such that each observation contains the summary statistics for a single level of the group= variable. The data set must have variables containing the group levels, sample sizes, means, and standard deviations. Optionally, variables for BY-group processing may also appear, but if specified, the data set must be sorted by the BY variables prior to calling the %SUM_GLM macro.
The following parameters are required when using the macro:
The following parameters are optional:
The macro creates the data set _WORKING which can be directly analyzed using PROC GLM using the FREQ statement:
The response variable in this data set is named Y. If the GLM analysis done by the macro is not exactly as desired, you can use GLM to reanalyze the _WORKKING data set by including the above FREQ statement in your GLM step.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
In this example, a one-way analysis is done for each of two BY groups (A and B). To illustrate the equivalence of this method of analyzing summary data to analyzing the original data, the example begins with the analysis of an unsummarized data set. The data are then summarized and an analysis of the summarized data is done using the %SUM_GLM macro
data fulldata; input bygroup $ treat response @@; cards; A 1 7.6 A 1 8.3 A 1 7.6 A 2 8.5 A 2 8.7 A 2 7.7 A 2 8.3 A 2 8.7 A 3 6.8 A 3 6.7 A 3 6.6 A 3 6.4 A 4 7.4 A 4 6.5 A 4 6.8 B 1 15.5 B 1 13.8 B 1 14.2 B 1 17.3 B 2 10.6 B 2 12.6 B 2 15.7 B 2 12.6 B 2 13.5 B 2 11.8 B 3 20.5 B 3 17.7 B 3 19.1 B 3 21.1 B 3 16.9 B 3 18.7 B 4 16.4 B 4 13.8 B 4 17.4 B 4 18.8 B 4 19.1 B 5 16.1 B 5 14.4 B 5 13.0 ;
The following statements perform the one-way analysis of the original unsummarized data. For brevity, the ODS SELECT statement restricts the tables that are displayed.
ods select overallanova fitstatistics lsmeans diff; proc glm data=fulldata; title "One-way analysis of unsummarized data"; by bygroup; class treat; model response = treat; lsmeans treat / stderr tdiff e; run;
Following are the analysis results for each BY group.
These statements display the summary statistics for each BY group of the original data.
proc sort data=fulldata; by bygroup; run; proc means data=fulldata mean std; by bygroup; class treat; var response; title "Summary statistics from original data"; run;
The MEANS Procedure
bygroup=A
bygroup=B
|
The following illustrates creating the input data set of summary statistics using a DATA step. This is the method you would use if you were presented with a listing of the summary statistics such as the above.
data summary; input count means std bygroup $ treat; cards; 3 7.8333 0.4041 A 1 5 8.3800 0.4147 A 2 4 6.6250 0.1708 A 3 3 6.9000 0.4583 A 4 4 15.200 1.5769 B 1 6 12.800 1.7216 B 2 6 19.000 1.6038 B 3 5 17.100 2.1424 B 4 3 14.500 1.5524 B 5 ;
Since we have the unsummarized data in this example, note that the summary data set could be created using PROC SUMMARY as follows:
proc summary data=fulldata nway; class bygroup treat; var response; output out=summary2 mean=means std=std n=count; run; proc print; run;
While not necessary in this case since the data are in sorted order, the input data set must generally be sorted by the BY variables before analysis by the macro.
proc sort data=summary; by bygroup; run;
The following statements define and run the SUM_GLM macro on the summary statistics to reproduce the analyses of the original data. Slight numerical differences from the analysis of unsummarized data are due to using limited precision when inputting the summary statistics above.
/* Define the SUM_GLM macro */ %inc "<location of your file containing the SUM_GLM macro>"; ods select overallanova fitstatistics lsmeans diff; %sum_glm(Data=summary, N=count, Mean=means, StdDev=std, LSopts=stderr tdiff e, By=bygroup, Group=Treat)
The GLM Procedure
Dependent Variable: y
bygroup=A
The GLM Procedure
Least Squares Means
bygroup=A
The GLM Procedure
Dependent Variable: y
bygroup=B
The GLM Procedure
Least Squares Means
bygroup=B
|
Right-click on the link below and select Save to save
the %SUM_GLM macro definition
to a file. It is recommended that you name the file
sum_glm.sas
.
Type: | Sample |
Topic: | Analytics ==> Regression Analytics ==> Analysis of Variance Analytics ==> Longitudinal Analysis SAS Reference ==> Procedures ==> GLM |
Date Modified: | 2007-08-14 03:03:09 |
Date Created: | 2005-01-13 15:03:51 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/STAT | All | n/a | n/a |