BookmarkSubscribeRSS Feed
SantaCruz
Calcite | Level 5

Hi All,

I have encountered a problem I hoped someone here would be able to help me out with. The setup is I want to estimate a simple OLS, proc reg, on observations prior to a specified data and then predict on all observations in my sample to calculate residuals. The estimation command is

proc reg data=analy6_w2;

  model felt_200 = jan feb mar apr may jun jul aug sep okt nov dec /noint ;

  where dto <= 17897;

run;

However,  17897 is end of 2008 and I would to use to parameter estimate on the monthly dummies for prediction and calculations of residuals on my full sample (dto goes to 18840). Basically want I would like is to subtract the monthly average in jan 2008 from the monthly average in jan 2009, and jan 2010 and 2011 same with feb and so on.

At the moment I am doing by hand like this:

data analy6_w3;

set analy6_w2;

IF jan=1 THEN res = felt_200 - 134662;

IF feb=1 THEN res = felt_200 - 130125;

IF mar=1 THEN res = felt_200 - 156824;

IF apr=1 THEN res = felt_200 - 139780;

IF may=1 THEN res = felt_200 - 157908;

IF jun=1 THEN res = felt_200 - 119785;

IF jul=1 THEN res = felt_200 - 128617;

IF aug=1 THEN res = felt_200 - 113352;

IF sep=1 THEN res = felt_200 - 119487;

IF okt=1 THEN res = felt_200 - 186362;

IF nov=1 THEN res = felt_200 - 149815;

IF dec=1 THEN res = felt_200 - 290729;

run;

But there must be an easier way.

Thanks in advance!

Peer

1 REPLY 1
Reeza
Super User

Your question doesn't seem to match your title, so I'll answer the question, or try, I'm not 100% sure what you're after.

I think you're doing some sort of time series analysis and that looking into PROC EXPAND might be worthwhile.

See the last tip/trick on this page http://www.sas.com/offices/NA/canada/downloads/presentations/Vansug-Nov2011/1111Newsletter.pdf

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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