Programming the statistical procedures from SAS

How to estimate on a subsample and predict on full?

Reply
N/A
Posts: 1

How to estimate on a subsample and predict on full?

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

Super User
Posts: 18,498

How to estimate on a subsample and predict on full?

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

Ask a Question
Discussion stats
  • 1 reply
  • 140 views
  • 0 likes
  • 2 in conversation