Date: Thu, 1 Oct 2009 17:39:03 0500
ReplyTo: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SASL@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Proc GLM and Categorical variables
InReplyTo: <3F23EB586C5943C6A190661497EE1AED@Aragorn>
ContentType: text/plain; charset=windows1252
I guess CLASSES is similar to VARIABLES for VAR.
33775 proc print data=sashelp.class;
33776 variables name;
33777 run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
33778 proc summary data=sashelp.class;
33779 classes age sex;
33780 variables weight height;
33781 output out=counts;
33782 run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.COUNTS has 100 observations and 7 variables.
33783 proc glmmod data=sashelp.class;
33784 classes age sex;
33785 model weight height = agesex;
33786 run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
On 8/9/09, Daniel Nordlund <djnordlund@verizon.net> wrote:
> > Original Message
> > From: Peter Flom [mailto:peterflomconsulting@mindspring.com]
> > Sent: Sunday, August 09, 2009 2:07 PM
> > To: Daniel Nordlund; SASL@LISTSERV.UGA.EDU
> > Subject: Re: Proc GLM and Categorical variables
> >
> > Orin Richards wrote
> > >> Hi All,
> > >> I am using PROC GLM to do some analysis on age and treatment
> > >> (treat). Now treat is my categorical variable and age my
> > >> continuous variable. The categorical variable treat has the
> > >> followin levels high, low and control. By default PROC GLM
> > >> uses alphabethical ordering to determine the reference
> > >> category, therefore in my case "low" is the reference
> > >> category. I would like to know if there is a way to tell
> > >> PROC GLM to use" control" as the reference category. I can
> > >> create a new treatrment variable give the the appropriate
> > >> names so that "control" is the reference category. I would
> > >> however like to know if PROC GLM has an option that allows
> > >> you tell it what you would like the reference category to be.
> >
> > Daniel Nordlund replied
> >
> > >You don't don’t show your code , or example data, but you
> > should be able to use ref='control' on the class statement.
> > Something like
> > >
> > >proc glm data=have;
> > > class treat(ref='control');
> > > model y = treat / solution;
> > >quit;
> > >
> >
> > This would be logical. It is how SAS should behave, and it
> > works with PROC LOGISTIC but ....not with GLM.
> >
> > data today;
> > input age treat $ @@;
> > datalines;
> > 15 C 16 C 17 C 18 C 19 C 20 C
> > 19 L 19 L 20 L 18 L 20 L 25 L
> > 19 H 20 H 21 H 22 H 13 H 26 H
> > ;;;
> > run;
> >
> > proc glm data = today;
> > class treat;
> > model age = treat/solution;
> > run;
> >
> > runs, and uses "L" as reference. But
> > <<<<
> > proc glm data=today;
> > class treat (ref='C');
> > model age = treat / solution;
> > quit;
> > >>>>
> >
> > Yields a syntax error:
> >
> > NOTE: The previous statement has been deleted.
> > ERROR 22322: Syntax error, expecting one of the following: a
> > name, ;, , /, :, _ALL_,
> > _CHARACTER_, _CHAR_, _NUMERIC_.
> > ERROR 76322: Syntax error, statement will be ignored.
> > 36 model age = treat / solution;
> > ERROR: Variable treat should be either numeric or in CLASSES list.
> > NOTE: The previous statement has been deleted.
> >
> > Searching the SASL archives yields this answer from Robin
> > High, to a very similar question
> >
> > You can either apply a reverse coded format to the group
> > variable with the
> > order=formatted option:
> >
> > proc format;
> > value ord 1='3_g0' 2='2_g1' 3='1_g2';
> > run;
> >
> > PROC GLM DATA=mll order=formatted;
> > CLASS group;
> > MODEL y = group / solution;
> > FORMAT group ord. ;
> > RUN; quit;
> >
> > or sort the data in descending group order and apply the
> > order=data option
> >
> >
> > <<<<
> > You can either apply a reverse coded format to the group
> > variable with the
> > order=formatted option:
> >
> > proc format;
> > value ord 1='3_g0' 2='2_g1' 3='1_g2';
> > run;
> >
> > PROC GLM DATA=mll order=formatted;
> > CLASS group;
> > MODEL y = group / solution;
> > FORMAT group ord. ;
> > RUN; quit;
> >
> > or sort the data in descending group order and apply the
> > order=data option
> >
> > proc sort data = mll; by descending group; run;
> >
> > PROC GLM DATA=mll order=data;
> > CLASS group;
> > MODEL y = group / solution;
> > RUN; quit;
> > >>>>>
> >
> >
> > Maybe SAS will fix this up at some point.
> >
> >
> > Peter
> >
> >
>
> Peter points out that my "solution" does not work in GLM, and he is correct. The error message indicates that to use this syntax the variable must be numeric or in a CLASSES list. Can anyone point to somewhere in the documentation that CLASSES lists are discussed. I have searched for CLASSES but SAS "helpfully" shows every reference to the word CLASS in the documentation. If classes is discussed, it is the needle in the haystack.
>
> Dan
>
> Daniel Nordlund
> Bothell, WA USA
>
