BookmarkSubscribeRSS Feed
zzstudent20
Calcite | Level 5

Hi,

 

I would like to rearrange only the estimates and standard errors given by the Stat.Glimmix.LSMeans template as depicted below.

trt Least Squares Means (original)
trtestimatestandard erroretc
12.50.32etc
220.32etc
    
trt Least Squares Means (goal)
12
estimatestderrestimatestderr
2.50.3220.32

 

Initially, I thought learning how to use PROC TEMPLATE would solve my problem. After spending the time to understand how PROC TEMPLATE works, I realized that I need to have the estimates and standard errors in a dataset first, at least that's what I think I need to do first.

 

I tried using output with pred and stderr in my Glimmix procedure, but that did not give me the above values in the output dataset I created.

 

Then, I read about ODS TRACE in a thread here and learned about Stat.Glimmix.LSMeans and its parent Stat.Glimmix.tTests. This is where I am not sure how to proceed. Am I heading in the right direction? Or, am I unaware of another more efficient way to achieve my goal?

 

Thank you!

 

 

3 REPLIES 3
ballardw
Super User

Show use the Proc code you are currently using.

Likely you want an ODS OUTPUT statement to send the result of a table to a data set.

The ODS trace shows the names of the tables your code uses:

It will be a couple step process. First you run code like this pseudo code:

ods trace on;
proc anyproc data=yourdata;
<proc statements>
run;
ods trace off;

Then look in the LOG for the table names used. OR if you can read SAS documentation the Details section of most procs documentation will have a section named "ODS Table Names" that will show the table name and the option used in the code to generate the table.

Using that information you RERUN the proc code with the ODS OUTPUT statement(s) you want.

proc anyproc data=yourdata;
ods output aresulttable = myresultdataset;
<proc statements>
run;

 

 

 

zzstudent20
Calcite | Level 5

Hi ballardw,

 

Thank you for the suggestions! My apologies for the delayed response. I am using SAS 9.4 on Windows 10 and below is the PROC code I am currently using that includes ODS TRACE and my DATA step. Unfortunately, your suggestions did not work in my case. Of course, I could have followed your suggestions incorrectly.

 

options center nonumber; options ls=99; options ps=66;
data data;
title 'Code with Random Data';
input year block trt va rep PH;
cards;
1	1	1	1	1	2.82
1	1	1	1	2	3.311
1	1	1	1	3	1.944
1	1	1	1	4	2.048
1	1	1	2	1	2.789
1	1	1	2	2	3.413
1	1	1	2	3	3.818
1	1	1	2	4	3.812
1	1	1	3	1	5.493
1	1	1	3	2	2.266
1	1	1	3	3	3.437
1	1	1	3	4	1.471
1	1	1	5	1	2.037
1	1	1	5	2	1.873
1	1	1	5	3	1.463
1	1	1	5	4	2.983
1	1	1	6	1	2.802
1	1	1	6	2	2.013
1	1	1	6	3	2.646
1	1	1	6	4	2.399
1	1	2	1	1	4.512
1	1	2	1	2	2.892
1	1	2	1	3	4.57
1	1	2	1	4	2.865
1	1	2	2	1	3.373
1	1	2	2	2	3.293
1	1	2	2	3	3.782
1	1	2	2	4	3.881
1	1	2	3	1	2.678
1	1	2	3	2	2.257
1	1	2	3	3	4.786
1	1	2	3	4	5.43
1	1	2	5	1	2.123
1	1	2	5	2	4.372
1	1	2	5	3	1.964
1	1	2	5	4	1.824
1	1	2	6	1	1.766
1	1	2	6	2	1.387
1	1	2	6	3	3.151
1	1	2	6	4	2.495
1	2	1	1	1	4.387
1	2	1	1	2	2.369
1	2	1	1	3	1.587
1	2	1	1	4	1.813
1	2	1	2	1	3.824
1	2	1	2	2	1.835
1	2	1	2	3	1.482
1	2	1	2	4	2.569
1	2	1	3	1	3.522
1	2	1	3	2	2.279
1	2	1	3	3	2.212
1	2	1	3	4	2.225
1	2	1	5	1	4.254
1	2	1	5	2	2.072
1	2	1	5	3	4.01
1	2	1	5	4	2.337
1	2	1	6	1	2.022
1	2	1	6	2	1.464
1	2	1	6	3	1.38
1	2	1	6	4	1.436
1	2	2	1	1	2.2
1	2	2	1	2	2.947
1	2	2	1	3	2.035
1	2	2	1	4	2.015
1	2	2	2	1	3.015
1	2	2	2	2	4.212
1	2	2	2	3	3.747
1	2	2	2	4	1.815
1	2	2	3	1	4.227
1	2	2	3	2	4.056
1	2	2	3	3	3.857
1	2	2	3	4	3.24
1	2	2	5	1	4.568
1	2	2	5	2	6.188
1	2	2	5	3	2.12
1	2	2	5	4	2.257
1	2	2	6	1	2.022
1	2	2	6	2	4.509
1	2	2	6	3	2.353
1	2	2	6	4	3.479
2	1	1	1	1	6.099
2	1	1	1	2	5.531
2	1	1	1	3	3.535
2	1	1	1	4	2.714
2	1	1	2	1	2.641
2	1	1	2	2	2.751
2	1	1	2	3	3.583
2	1	1	2	4	2.592
2	1	1	3	1	2.471
2	1	1	3	2	3.074
2	1	1	3	3	7.628
2	1	1	3	4	3.825
2	1	1	5	1	3.442
2	1	1	5	2	3.406
2	1	1	5	3	3.501
2	1	1	5	4	2.908
2	1	1	6	1	2.861
2	1	1	6	2	2.392
2	1	1	6	3	2.528
2	1	1	6	4	2.723
2	1	2	1	1	2.374
2	1	2	1	2	2.904
2	1	2	1	3	3.026
2	1	2	1	4	3.451
2	1	2	2	1	4.136
2	1	2	2	2	1.813
2	1	2	2	3	1.422
2	1	2	2	4	4.25
2	1	2	3	1	3.056
2	1	2	3	2	1.911
2	1	2	3	3	3.839
2	1	2	3	4	3.195
2	1	2	5	1	3.042
2	1	2	5	2	2.301
2	1	2	5	3	4.185
2	1	2	5	4	3.577
2	1	2	6	1	2.213
2	1	2	6	2	3.729
2	1	2	6	3	2.214
2	1	2	6	4	3.043
2	2	1	1	1	2.106
2	2	1	1	2	3.312
2	2	1	1	3	2.577
2	2	1	1	4	3.929
2	2	1	2	1	2.771
2	2	1	2	2	2.94
2	2	1	2	3	3.281
2	2	1	2	4	2.244
2	2	1	3	1	1.839
2	2	1	3	2	3.49
2	2	1	3	3	2.117
2	2	1	3	4	2.335
2	2	1	5	1	3.508
2	2	1	5	2	5.813
2	2	1	5	3	3.762
2	2	1	5	4	4.858
2	2	1	6	1	3.72
2	2	1	6	2	5.405
2	2	1	6	3	3.614
2	2	1	6	4	3.537
2	2	2	1	1	2.108
2	2	2	1	2	6.027
2	2	2	1	3	2.061
2	2	2	1	4	1.467
2	2	2	2	1	2.682
2	2	2	2	2	1.872
2	2	2	2	3	4.446
2	2	2	2	4	2.54
2	2	2	3	1	2.29
2	2	2	3	2	1.803
2	2	2	3	3	2.698
2	2	2	3	4	0.68
2	2	2	5	1	3.065
2	2	2	5	2	1.015
2	2	2	5	3	4.453
2	2	2	5	4	6.485
2	2	2	6	1	3.403
2	2	2	6	2	1.808
2	2	2	6	3	2.158
2	2	2	6	4	1.456
;

proc sort; by va year block trt;
proc means noprint; by va year block trt;
var PH;
output out=meandata mean=PH;
run;

ods trace on;

proc glimmix data=meandata nobound;by va;
class year block trt;
model PH = trt year trt*year /ddfm=satterth;
random block ;
lsmeans trt/pdiff lines cl;
run;

ods trace off;

 

ODS TRACE shows that the name of the table template that contains the estimates and standard errors that I need to extract is Stat.Glimmix.LSMeans.

 

Output Added:
-------------
Name:       LSMeans
Label:      trt LS-Means
Template:   Stat.Glimmix.LSMeans
Path:       Glimmix.ByGroup5.LSMeans.LSMeans

 

However, using 'Pred' and 'StdErr' based on the info provided in Table 49.15:Keywords for Output Statistics in the SAS Documentation for GLIMMIX does not yield the same estimates and standard errors I get in the Stat.Glimmix.LSMeans table. Below is the the code with the OUTPUT STATEMENT and PROC TEMPLATE code to visualize the data.

 

proc glimmix data=meandata nobound;by va;
class year block trt;
model PH = trt year trt*year /ddfm=satterth;
random block ;
lsmeans trt/pdiff lines cl;
output out=test pred=p stderr=se;
run;

###Output Data in Table Format###
proc template;
	define table mytable;
	end;
run;

data _null_;
	set test;
	file print ods = (template='mytable');
	put _ods_;
run;

When I try to use Stat.Glimmix.LSMeans in the OUTPUT STATEMENT, I get "ERROR:Statement is not valid or it is used out of proper order." My code is below.

 

proc glimmix data=meandata nobound;by va;
class year block trt;
model PH = trt year trt*year /ddfm=satterth;
random block ;
lsmeans trt/pdiff lines cl;
output Stat.Glimmix.LSMeans=myresults;
run;

Unless the Table 49.15 is not the correct table, I am not sure what else to do.

 

Thank you.

zzstudent20
Calcite | Level 5
My friend pointed out that I forgot "ODS" in my output statement. Doing that and using LSMeans=myresults gave me the data set I need. Problem solved.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 712 views
  • 0 likes
  • 2 in conversation