From: ManojK on
Hi all,

I have a data set of Completely randomized design. I want to use
different data sets and display output according to my need. So I use
ODS for this. Now my program is working only for this data set. I want
to build a macro which can take different input data sets and display
same formatted output (as when you run sample program CRD.txt given
below).

I have attached my code file below. You can run it in SAS to get the
output. Now help me in changing this program to an independent macro.

In short, I need a SAS program which uses macro facility so that in
future I just enter data and it shows the output i.e. I need a program
in which there will be same model statement every time. It should work
for different data sets.

In my crd program I do a little bit of programming on ODS output sets
so that I get my output as I need. If you look it carefully you will
understand what I have done. I just delete unnecessary output,
appended Type III Model anova with Overall anova, display lsmeans
pdiff matrix, display tikey grouping lines with the help of proc
Glimmix etc.

I need the same output as when you run crd program. Please give your
suggestions

SAS program "CRD.sas"

data crd;
input rep trt yield;
cards;
1 1 3472.222222
1 2 2876.984127
1 3 3511.904762
1 4 1706.349206
1 5 1250
2 1 3343.253968
2 2 2936.507937
2 3 3571.428571
2 4 1666.666667
3 1 3353.174603
3 2 3005.952381
3 3 3531.746032
4 2 2767.857143
4 3 3353.174603
4 4 1626.984127
4 5 1309.52381
;

ods listing close;
proc glm data=crd;
class trt;
model yield=trt/ss3;
lsmeans trt/pdiff;
ods output OverallANOVA = finalanova;
ods output ModelANOVA = anova;
ods output FitStatistics = fitstat;
ods output LSMeans = means;
ods output Diff = diffmat;
run;
ods listing;

data crd_mk;
set anova (drop=Dependent HypothesisType);
run;

data crd_mk1;
set finalanova (drop=Dependent);
run;

proc iml;
edit crd_mk1;
p={1};
delete point p; /*delete first obsevation from
finalanova data set*/
run;

proc append base=crd_mk data=crd_mk1; /*Appending the anova and
finalanova datasets*/
run;

proc print data=crd_mk noobs; /*print appended Anova
table*/
run;

data fitvalues;
set fitstat;
run;

proc print data=fitvalues noobs; /*print fit staistics
information*/
run;

data crd_means;
set means (drop=Effect Dependent);
run;

proc print data=crd_means noobs; /*print treatment Lsmeans
along with LSmean number*/
run;

data crd_diffmat;
set diffmat (drop=Effect Dependent Rename=(RowName=i_j));

proc print data=crd_diffmat noobs; /*print P-value matrix of
diff. treatment numbers*/
run;

ods listing close;
proc glimmix data=crd; /*proc glimmix is used to display tukey
grouping in
class trt; ascending order
of trt lsmeans statement*/
model yield = trt;
lsmeans trt/adjust=tukey lines;
ods output LSMLines = CRD_lslines;
ods select LSMLines;
run;
ods listing;

data crdgrp;
set CRD_lslines (drop = Method EqLS1-EqLS5 Rename=(Line1 =
Grouping));;
run;

proc sort data=crdgrp;
by trt;
run;

proc iml;
edit crdgrp;
find all where(Effect={" "}) into d;
delete point d;
run;

title1 'Tukey-Kramer Grouping for trt Least Squares Means';
title2 'LS-means with the same letter are not significantly
different.';

proc print data=crdgrp noobs; /*print only three variables*/
var trt Estimate Grouping;
run;

Thanks in anticipation.

Regards,
Manoj Khandelwal
Senior Research Fellow,
IASRI, Pusa, Delhi
From: Patrick on
Hi Manoj

Normally people ask for help when they run into issues while trying to
solve a problem.
You're asking for a solution for something you haven't even started
working on.
Is this because you haven't any SAS macro skills at all?

Regards
Patrick
From: Reeza on
On Apr 17, 2:55 am, ManojK <khandelwalmano...(a)gmail.com> wrote:
> Hi all,
>
> I have a data set of Completely randomized design. I want to use
> different data sets and display output according to my need. So I use
> ODS for this. Now my program is working only for this data set. I want
> to build a macro which can take different input data sets and display
> same formatted output (as when you run sample program CRD.txt given
> below).
>
> I have attached my code file below. You can run it in SAS to get the
> output. Now help me in changing this program to an independent macro.
>
> In short, I need a SAS program which uses macro facility so that in
> future I just enter data and it shows the output i.e. I need a program
> in which there will be same model statement every time. It should work
> for different data sets.
>
> In my crd program I do a little bit of programming on ODS output sets
> so that I get my output as I need. If you look it carefully you will
> understand what I have done. I just delete unnecessary output,
> appended Type III Model anova with Overall anova, display lsmeans
> pdiff matrix, display tikey grouping lines with the help of proc
> Glimmix etc.
>
> I need the same output as when you run crd program. Please give your
> suggestions
>
> SAS program "CRD.sas"
>
> data crd;
> input rep trt yield;
> cards;
> 1 1 3472.222222
> 1 2 2876.984127
> 1 3 3511.904762
> 1 4 1706.349206
> 1 5 1250
> 2 1 3343.253968
> 2 2 2936.507937
> 2 3 3571.428571
> 2 4 1666.666667
> 3 1 3353.174603
> 3 2 3005.952381
> 3 3 3531.746032
> 4 2 2767.857143
> 4 3 3353.174603
> 4 4 1626.984127
> 4 5 1309.52381
> ;
>
> ods listing close;
> proc glm data=crd;
>         class trt;
>         model yield=trt/ss3;
>         lsmeans trt/pdiff;
>         ods output OverallANOVA = finalanova;
>         ods output ModelANOVA = anova;
>         ods output FitStatistics = fitstat;
>         ods output LSMeans = means;
>         ods output Diff = diffmat;
> run;
> ods listing;
>
> data crd_mk;
>         set anova (drop=Dependent HypothesisType);
> run;
>
> data crd_mk1;
>         set finalanova (drop=Dependent);
> run;
>
> proc iml;
>         edit crd_mk1;
>         p={1};
>         delete point p;                   /*delete first obsevation from
> finalanova data set*/
> run;
>
> proc append base=crd_mk data=crd_mk1;     /*Appending the anova and
> finalanova datasets*/
> run;
>
> proc print data=crd_mk noobs;             /*print appended Anova
> table*/
> run;
>
> data fitvalues;
>         set fitstat;
> run;
>
> proc print data=fitvalues noobs;          /*print fit staistics
> information*/
> run;
>
> data crd_means;
>         set means (drop=Effect Dependent);
> run;
>
> proc print data=crd_means noobs;        /*print treatment Lsmeans
> along with LSmean number*/
> run;
>
> data crd_diffmat;
>         set diffmat (drop=Effect Dependent Rename=(RowName=i_j));
>
> proc print data=crd_diffmat noobs;        /*print P-value matrix of
> diff. treatment numbers*/
> run;
>
> ods listing close;
> proc glimmix data=crd;   /*proc glimmix is used to display tukey
> grouping in
>         class trt;                                        ascending order
> of trt lsmeans statement*/
>         model yield = trt;
>         lsmeans trt/adjust=tukey lines;
>         ods output LSMLines = CRD_lslines;
>         ods select LSMLines;
> run;
> ods listing;
>
> data crdgrp;
>         set CRD_lslines (drop = Method EqLS1-EqLS5 Rename=(Line1 =
> Grouping));;
> run;
>
> proc sort data=crdgrp;
>         by trt;
> run;
>
> proc iml;
>         edit crdgrp;
>         find all where(Effect={" "}) into d;
>         delete point d;
> run;
>
> title1 'Tukey-Kramer Grouping for trt Least Squares Means';
> title2 'LS-means with the same letter are not significantly
> different.';
>
> proc print data=crdgrp noobs;             /*print only three variables*/
>         var trt Estimate Grouping;
> run;
>
> Thanks in anticipation.
>
> Regards,
> Manoj Khandelwal
> Senior Research Fellow,
> IASRI, Pusa, Delhi

Sounds like a really basic macro with just a dataset name
field...there are a lot of sample macro's out their that do that.
Here's a basic tutorial.

http://www.nesug.org/proceedings/nesug03/bt/bt009.pdf

Good luck.
From: ManojK on
On Apr 19, 11:07 pm, montura <montura...(a)gmail.com> wrote:
> I think Manoj is trying to get his homework done while still in class.
> Some of the instructors in India are really strict that way you know.

Hi Patrick,

Thanks for your comments.
You are saying right I want solution not trying for myself.
I sit for 2 hours read some macro PDFs.
Now I have done with my macro. I have made it and it works fine for
different data sets as I wish.

Regards,
Manoj
From: montura on
I think Manoj is trying to get his homework done while still in class.
Some of the instructors in India are really strict that way you know.