DATA Step, Macro, Functions and more

can i have a variable 'R' in Model statement?

Reply
Contributor
Posts: 24

can i have a variable 'R' in Model statement?

[ Edited ]

hello one of the variables in my dataset is just 'R'. I'm and trying to fit a few log-linear models but whenever i type in 'R' either alone or within an interaction term it turns blue. i looked it up and see that under the Model statement, R requests analysis of residuals. However my output seems like what is should be for the GENMOD procedure i ran and there are no plots/tables referencing residuals. In my analysis of maximum likelihood tables, the reference level of 'R' is correct referenced  so it appears that it worked as it should have 

 

But i'm just worried that my values are off. Does anyone know if this disrupts my output values?

Here is my code but on here it doesn't color it the way it is on my computer. Everything is the same expect the two 'r' in the interaction terms are blue.

proc genmod data=lm.hw4q1;
class m (ref='No') i (ref='No') r (ref= 'West') /param=reference;
model count = r m i i*r m*r /dist=Poisson;
run;

 

 

Trusted Advisor
Posts: 1,831

Re: can i have a variable 'R' in Model statement?

Posted in reply to iressa131

Have you tried to rename the variable R ?

(I'm not familiar with that proc and hope I have renamed the right Rs in your code)

proc genmod data=lm.hw4q1 (rename=(R=myR));
class m (ref='No') i (ref='No') myr (ref= 'West') /param=reference;
model count = myr m i i*myr m*myr /dist=Poisson;
run;
Super User
Posts: 9,868

Re: can i have a variable 'R' in Model statement?

Posted in reply to iressa131

The Enhanced Editor is not perfect in its decisions when to use which color, so it can interpret your variable name wrongly as an option (that would be used in a slightly other place like following a forward slash).

From my experience, as long as the log looks like it should, you are OK.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Community Manager
Posts: 3,378

Re: can i have a variable 'R' in Model statement?

Posted in reply to KurtBremser

@KurtBremser is correct about the editor and how it colors keywords.  If the token is a valid keyword in the context of the statement, it gets the keyword color treatment.  But ultimately it's the SAS language processor that decides how to interpret it. 

 

If you want to be more explicit about this as a variable name, you can try the literal syntax -- but I'm not sure it makes this more readable:

 

proc genmod data=lm.hw4q1;
class m (ref='No') i (ref='No') 'r'n (ref= 'West') /param=reference;
model count = 'r'n m i i*'r'n m*'r'n /dist=Poisson;
run;
Super User
Posts: 13,293

Re: can i have a variable 'R' in Model statement?

Posted in reply to iressa131

The "R" to request residuals is an option which would go after the /. If you were to include in in your model the statement would be:

model count = r m i i*r m*r /  dist=Poisson  R;

So there should be no problem with a variable named R or Poisson or Pred or any of the other options. Though the code might appear somewhat misleading ...

 

Ask a Question
Discussion stats
  • 4 replies
  • 138 views
  • 3 likes
  • 5 in conversation