BookmarkSubscribeRSS Feed
saslearner0903
Calcite | Level 5

Hello~ guys~

I have a question about R-square using proc reg.

My sample consists of daily data.

I want to run regression by both group and year and to get R square by group.

Data structure is as follows.

group  dept  indpt1  indpt2     date        year

     1                                19950101  1995

     2                                19960205  1996

     3                                19970310  1997


When I run the regression with following code, it generates residual=0 and Rsquare=1 for every observation.

However, it should not be the case since I got positive R-square with part of the sample using another program .

What is the problem of my code and how can I correct this problem?

Any comments are appreciated.

-------------------------------------------------------------------------------------------------------------------------------------------------------

proc sort data=examp; by group year;

run;

proc reg data = examp

noprint tableout edf usscp outest = result_examp;

by group year;

model dpt = indpt1 indpt2;

output out=result_R r=rsqr;

run;

Thank you.

1 REPLY 1
SteveDenham
Jade | Level 19

Given your dataset, you are trying to regress a single point.  You have only one record per group.  I would suggest dropping the group variable from the by statement to get the relationship for each year across all groups, and then dropping year variable (and re-inserting group) to look at the relationship for each group across time.  Does that make any sense relative to the objective of your analysis?

Steve Denham

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 724 views
  • 0 likes
  • 2 in conversation