BookmarkSubscribeRSS Feed
pmorel3
Obsidian | Level 7

Hello,

 

I have an error message when I only run this macro: "%r2gain(dmspe09,'dmspe09', US, 14);". For the 4 others, everything is fine.

I do not know where I did a mistake in my codes.

I also notice that I have missing variables in my dataset "previsions_US" (pred_dmspe09, res2_dmspe09, f_dmspe09, res2_n_dmspe09).

Could you please tell me where I did wrong ?

 

 

 

5590  /*Calculer les prévisions combinées selon les 5 méthodes différentes*/
5591
5592  data previsions_US;
5593  merge m.oos_zdp m.oos_zdy m.oos_zep m.oos_zde m.oos_zsvar /*m.oos_zcsp*/ m.oos_zbm m.oos_zntis m.oos_ztbl m.oos_zlty
5593! m.oos_zltr m.oos_ztms m.oos_zdfy m.oos_zdfr m.oos_zinfl;
5594  by obs date;
5595
5596  pred_mean=mean(pred_zdp, pred_zdy, pred_zep, pred_zde, pred_zsvar, /*pred_zcsp, */pred_zbm, pred_zntis, pred_ztbl,
5596! pred_zlty, pred_zltr, pred_ztms, pred_zdfy, pred_zdfr, pred_zinfl);
5597  res2_mean=(act_oos-pred_mean)**2;
5598
5599  pred_mediane=median(pred_zdp, pred_zdy, pred_zep, pred_zde, pred_zsvar, /*pred_zcsp, */pred_zbm, pred_zntis, pred_ztbl,
5599!  pred_zlty, pred_zltr, pred_ztms, pred_zdfy, pred_zdfr, pred_zinfl);
5600  res2_mediane=(act_oos-pred_mediane)**2;
5601
5602  max=max(pred_zdp, pred_zdy, pred_zep, pred_zde, pred_zsvar, /*pred_zcsp, */pred_zbm, pred_zntis, pred_ztbl, pred_zlty,
5602! pred_zltr, pred_ztms, pred_zdfy, pred_zdfr, pred_zinfl);
5603  min=min(pred_zdp, pred_zdy, pred_zep, pred_zde, pred_zsvar, /*pred_zcsp, */pred_zbm, pred_zntis, pred_ztbl, pred_zlty,
5603! pred_zltr, pred_ztms, pred_zdfy, pred_zdfr, pred_zinfl);
5604
5605
5606  if (pred_zdp=max or pred_zdp=min) then v1=.; else v1=pred_zdp;
5607  if (pred_zdy=max or pred_zdy=min) then v2=.; else v2=pred_zdy;
5608  if (pred_zep=max or pred_zep=min) then v3=.; else v3=pred_zep;
5609  if (pred_zde=max or pred_zde=min) then v4=.; else v4=pred_zde;
5610  if (pred_zsvar=max or pred_zsvar=min) then v5=.; else v5=pred_zsvar;
5611  /*if (pred_zcsp=max or pred_zcsp=min) then v6=.; else v6=pred_zcsp;*/
5612  if (pred_zbm=max or pred_zbm=min) then v7=.; else v7=pred_zbm;
5613  if (pred_zntis=max or pred_zntis=min) then v8=.; else v8=pred_zntis;
5614  if (pred_ztbl=max or pred_ztbl=min) then v9=.; else v9=pred_ztbl;
5615  if (pred_zlty=max or pred_zlty=min) then v10=.; else v10=pred_zlty;
5616  if (pred_zltr=max or pred_zltr=min) then v11=.; else v11=pred_zltr;
5617  if (pred_ztms=max or pred_ztms=min) then v12=.; else v12=pred_ztms;
5618  if (pred_zdfy=max or pred_zdfy=min) then v13=.; else v13=pred_zdfy;
5619  if (pred_zdfr=max or pred_zdfr=min) then v14=.; else v14=pred_zdfr;
5620  if (pred_zinfl=max or pred_zinfl=min) then v15=.; else v15=pred_zinfl;
5621
5622  pred_trim=mean(v1, v2, v3, v4, v5, /*v6, */v7, v8, v9, v10, v11, v12, v13, v14, v15);
5623  res2_trim=(act_oos-pred_trim)**2;
5624
5625  phi09inv = phi09inv_zdp + phi09inv_zdy + phi09inv_zep + phi09inv_zde + phi09inv_zsvar + phi09inv_zcsp + phi09inv_zbm +
5625! phi09inv_zntis + phi09inv_ztbl + phi09inv_zlty + phi09inv_zltr + phi09inv_ztms + phi09inv_zdfy + phi09inv_zdfr +
5625! phi09inv_zinfl;
5626  w09_zdp = phi09inv_zdp / phi09inv; u09_zdp=w09_zdp*pred_zdp;
5627  w09_zdy = phi09inv_zdy / phi09inv; u09_zdy=w09_zdy*pred_zdy;
5628  w09_zep = phi09inv_zep / phi09inv; u09_zep=w09_zep*pred_zep;
5629  w09_zde = phi09inv_zde / phi09inv; u09_zde=w09_zde*pred_zde;
5630  w09_zsvar = phi09inv_zsvar / phi09inv; u09_zsvar=w09_zsvar*pred_zsvar;
5631  /*w09_zcsp = phi09inv_zcsp / phi09inv; u09_zcsp=w09_zcsp*pred_zcsp;*/
5632  w09_zbm = phi09inv_zbm / phi09inv; u09_zbm=w09_zbm*pred_zbm;
5633  w09_zntis = phi09inv_zntis / phi09inv; u09_zntis=w09_zntis*pred_zntis;
5634  w09_ztbl = phi09inv_ztbl / phi09inv; u09_ztbl=w09_ztbl*pred_ztbl;
5635  w09_zlty = phi09inv_zlty / phi09inv; u09_zlty=w09_zlty*pred_zlty;
5636  w09_zltr = phi09inv_zltr / phi09inv; u09_zltr=w09_zltr*pred_zltr;
5637  w09_ztms = phi09inv_ztms / phi09inv; u09_ztms=w09_ztms*pred_ztms;
5638  w09_zdfy = phi09inv_zdfy / phi09inv; u09_zdfy=w09_zdfy*pred_zdfy;
5639  w09_zdfr = phi09inv_zdfr / phi09inv; u09_zdfr=w09_zdfr*pred_zdfr;
5640  w09_zinfl = phi09inv_zinfl / phi09inv; u09_zinfl=w09_zinfl*pred_zinfl;
5641
5642  pred_dmspe09=sum(u09_zdp, u09_zdy, u09_zep, u09_zde, u09_zsvar, /*u09_zcsp, */u09_zbm, u09_zntis, u09_ztbl, u09_zlty,
5642! u09_zltr, u09_ztms, u09_zdfy, u09_zdfr, u09_zinfl);
5643  res2_dmspe09=(act_oos-pred_dmspe09)**2;
5644
5645  phi1inv = phi1inv_zdp + phi1inv_zdy + phi1inv_zep + phi1inv_zde + phi1inv_zsvar + /*phi1inv_zcsp +*/phi1inv_zbm +
5645! phi1inv_zntis + phi1inv_ztbl + phi1inv_zlty + phi1inv_zltr + phi1inv_ztms + phi1inv_zdfy + phi1inv_zdfr + phi1inv_zinfl
5645! ;
5646  w1_zdp = phi1inv_zdp / phi1inv; u1_zdp=w1_zdp*pred_zdp;
5647  w1_zdy = phi1inv_zdy / phi1inv; u1_zdy=w1_zdy*pred_zdy;
5648  w1_zep = phi1inv_zep / phi1inv; u1_zep=w1_zep*pred_zep;
5649  w1_zde = phi1inv_zde / phi1inv; u1_zde=w1_zde*pred_zde;
5650  w1_zsvar = phi1inv_zsvar / phi1inv; u1_zsvar=w1_zsvar*pred_zsvar;
5651  /*w1_zcsp = phi1inv_zcsp / phi1inv; u1_zcsp=w1_zcsp*pred_zcsp;*/
5652  w1_zbm = phi1inv_zbm / phi1inv; u1_zbm=w1_zbm*pred_zbm;
5653  w1_zntis = phi1inv_zntis / phi1inv; u1_zntis=w1_zntis*pred_zntis;
5654  w1_ztbl = phi1inv_ztbl / phi1inv; u1_ztbl=w1_ztbl*pred_ztbl;
5655  w1_zlty = phi1inv_zlty / phi1inv; u1_zlty=w1_zlty*pred_zlty;
5656  w1_zltr = phi1inv_zltr / phi1inv; u1_zltr=w1_zltr*pred_zdp;
5657  w1_ztms = phi1inv_ztms / phi1inv; u1_ztms=w1_ztms*pred_ztms;
5658  w1_zdfy = phi1inv_zdfy / phi1inv; u1_zdfy=w1_zdfy*pred_zdfy;
5659  w1_zdfr = phi1inv_zdfr / phi1inv; u1_zdfr=w1_zdfr*pred_zdfr;
5660  w1_zinfl = phi1inv_zinfl / phi1inv; u1_zinfl=w1_zinfl*pred_zinfl;
5661
5662  pred_dmspe1=sum(u1_zdp, u1_zdy, u1_zep, u1_zde, u1_zsvar, /*u1_zcsp, */u1_zbm, u1_zntis, u1_ztbl, u1_zlty, u1_zltr,
5662! u1_ztms, u1_zdfy, u1_zdfr, u1_zinfl);
5663  res2_dmspe1=(act_oos-pred_dmspe1)**2;
5664
5665  res2_n_oos=res_n_oos**2;
5666
5667  f_mean=res2_n_oos-(res2_mean-((pred_n_oos-pred_mean)**2));
5668  f_mediane=res2_n_oos-(res2_mediane-((pred_n_oos-pred_mediane)**2));
5669  f_trim=res2_n_oos-(res2_trim-((pred_n_oos-pred_trim)**2));
5670  f_dmspe09=res2_n_oos-(res2_dmspe09-((pred_n_oos-pred_dmspe09)**2));
5671  f_dmspe1=res2_n_oos-(res2_dmspe1-((pred_n_oos-pred_dmspe1)**2));
5672
5673  if 195001 le date le 197212 then periode="1950-1972";
5674  if 197301 le date le 199512 then periode="1973-1995";
5675  if 199601 le date le 201812 then periode="1996-2018";
5676
5677  keep obs date periode act_oos pred_n_oos res_n_oos res2_n_oos
5678      pred_zdp pred_zdy pred_zep pred_zde pred_zsvar /*pred_zcsp */pred_zbm pred_zntis pred_ztbl pred_zlty pred_zltr
5678! pred_ztms pred_zdfy pred_zdfr pred_zinfl
5679      res_zdp res_zdy res_zep res_zde res_zsvar /*res_zcsp */res_zbm res_zntis res_ztbl res_zlty res_zltr res_ztms
5679! res_zdfy res_zdfr res_zinfl
5680      res2_zdp res2_zdy res2_zep res2_zde res2_zsvar /*res2_zcsp */res2_zbm res2_zntis res2_ztbl res2_zlty res2_zltr
5680! res2_ztms res2_zdfy res2_zdfr res2_zinfl
5681      pred_mean pred_mediane pred_trim pred_dmspe09 pred_dmspe1
5682      res2_mean res2_mediane res2_trim res2_dmspe09 res2_dmspe1
5683      f_mean f_mediane f_trim f_dmspe09 f_dmspe1;
5684  run;
5685  proc print data=previsions_US;
5686  run;
5687
5688  data previsions_US; set previsions_US;
5689  if res2_mean=. then res2_n_mean=.; else res2_n_mean=res2_n_oos;
5690  if res2_mediane=. then res2_n_mediane=.; else res2_n_mediane=res2_n_oos;
5691  if res2_trim=. then res2_n_trim=.; else res2_n_trim=res2_n_oos;
5692  if res2_dmspe09=. then res2_n_dmspe09=.; else res2_n_dmspe09=res2_n_oos;
5693  if res2_dmspe1=. then res2_n_dmspe1=.; else res2_n_dmspe1=res2_n_oos;
5694  run;
5695
5696  proc print data=previsions_US;
5697  run;
5698
5699  PROC EXPORT DATA=previsions_US
5700              OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_prev_US.xlsx"
5701              DBMS=XLSX REPLACE;
5702  RUN;
5703
5704
5705
5706  /*Calculer les statistiques pour la signifiance du coefficient R2 et le profit generé */
5707
5708  %macro r2gain(methode, met, setvar, k);
5709
5710  proc summary n nway data=previsions_&setvar.(where= (periode in ("1973-1995" "1996-2018")));
5711  var res2_&methode. res2_n_&methode.;
5712  output out=coeff_det_&methode._&setvar._T(drop=_type_) sum=;run;
5713
5714  data coeff_det_&methode._&setvar._T;set coeff_det_&methode._&setvar._T;
5715  r2_&methode._CF_OS_T = 1-(res2_&methode./res2_n_&methode.);
5716  r2_adj_&methode._CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - &k.)*(1-r2_&methode._CF_OS_T);methode=&met.;
5717  keep r2_&methode._CF_OS_T r2_adj_&methode._CF_OS_T methode;run;
5718
5719  /*proc summary n nway data=previsions_&setvar.(where= (periode in ("1973-1995")));
5720  var res2_&methode. res2_n_&methode.;
5721  output out=coeff_det_&methode._&setvar._S2(drop=_type_) sum=;run;
5722
5723  data coeff_det_&methode._&setvar._S2;set coeff_det_&methode._&setvar._S2;
5724  r2_&methode._CF_OS_S2 = 1-(res2_&methode./res2_n_&methode.);
5725  r2_adj_&methode._CF_OS_S2 = 1-(_freq_-1)/(_freq_- 1 - &k.)*(1-r2_&methode._CF_OS_S2);methode=&met.;
5726  keep r2_&methode._CF_OS_S2 r2_adj_&methode._CF_OS_S2 methode;run;
5727
5728  proc summary n nway data=previsions_&setvar.(where= (periode in ("1996-2018")));
5729  var res2_&methode. res2_n_&methode.;
5730  output out=coeff_det_&methode._&setvar._S3(drop=_type_) sum=;run;
5731
5732  data coeff_det_&methode._&setvar._S3;set coeff_det_&methode._&setvar._S3;
5733  r2_&methode._CF_OS_S3 = 1-(res2_&methode./res2_n_&methode.);
5734  r2_adj_&methode._CF_OS_S3 = 1-(_freq_-1)/(_freq_- 1 - &k.)*(1-r2_&methode._CF_OS_S3);methode=&met.;
5735  keep r2_&methode._CF_OS_S3 r2_adj_&methode._CF_OS_S3 methode;run;*/
5736
5737
5738  proc reg data=previsions_&setvar.(where= (periode in ("1973-1995" "1996-2018"))) outest=f_&methode._stat_T edf outseb
5738! tableout;
5739  model f_&methode.= /MSE;quit;
5740
5741  /*proc reg data=previsions_&setvar.(where= (periode in ("1973-1995"))) outest=f_&methode._stat_S2 edf outseb tableout;
5742  model f_&methode.= /MSE;quit;
5743
5744  proc reg data=previsions_&setvar.(where= (periode in ("1996-2018"))) outest=f_&methode._stat_S3 edf outseb tableout;
5745  model f_&methode.= /MSE;quit;*/
5746
5747
5748  data t_&methode._T; set f_&methode._stat_T;
5749  if _type_="T"; keep intercept methode;methode=&met.;rename intercept=tstat_T;label intercept=tstat_T;run;
5750
5751  data pvalue_&methode._T; set f_&methode._stat_T;
5752  if _type_="PVALUE"; keep intercept methode; methode=&met.;rename intercept=PVALUE_T;label intercept=PVALUE_T;run;
5753
5754  /*data t_&methode._S2; set f_&methode._stat_S2;
5755  if _type_="T"; keep intercept methode;methode=&met.;rename intercept=tstat_S2;label intercept=tstat_S2;run;
5756
5757  data pvalue_&methode._S2; set f_&methode._stat_S2;
5758  if _type_="PVALUE"; keep intercept methode; methode=&met.;rename intercept=PVALUE_S2;label intercept=PVALUE_S2;run;
5759
5760  data t_&methode._S3; set f_&methode._stat_S3;
5761  if _type_="T"; keep intercept methode;methode=&met.;rename intercept=tstat_S3;label intercept=tstat_S3;run;
5762
5763  data pvalue_&methode._S3; set f_&methode._stat_S3;
5764  if _type_="PVALUE"; keep intercept methode; methode=&met.;rename intercept=PVALUE_S3;label intercept=PVALUE_S3;run;*/
5765
5766
5767  data previsions_&setvar.;
5768  merge previsions_&setvar. (in=a) varstock rend;
5769  by obs;
5770  if a;
5771  gamma=3;
5772
5773  w0_n=(1/gamma)*(pred_n_oos/var_CRSPSPvw);
5774  w_&methode.=(1/gamma)*(pred_&methode./var_CRSPSPvw);
5775
5776  w0_n_aj=w0_n;
5777  flag0=0;
5778  if w0_n<0 then do; w0_n_aj=0; flag0=1; end;
5779  if w0_n>1.5 then do; w0_n_aj=1.5; flag0=1; end;
5780  if w0_n=. then w0_n_aj=.;
5781
5782  w_&methode._aj=w_&methode.;
5783  flag_&methode.=0;
5784  if w_&methode.<0 then do; w_&methode._aj=0;flag_&methode.=1; end;
5785  if w_&methode.>1.5 then do; w_&methode._aj=1.5;flag_&methode.=1; end;
5786  if w_&methode.=. then w_&methode._aj=.;
5787
5788  rendp_n = w0_n*CRSPSPvw + (1-w0_n)*Rfree;
5789  rendp_&methode. = w_&methode.*rtsx+ (1-w_&methode.)*Rfree;
5790
5791  rendp_n_aj = w0_n_aj*CRSPSPvw + (1-w0_n_aj)*Rfree;
5792  rendp_&methode._aj = w_&methode._aj*CRSPSPvw + (1-w_&methode._aj)*Rfree;
5793  run;
5794
5795  proc summary n nway data=previsions_&setvar.(where= (periode in ("1973-1995" "1996-2018")));
5796  var rendp_n rendp_&methode. rendp_n_aj rendp_&methode._aj;
5797  output out=gain_T (drop=_type_ _freq_) mean(rendp_n)=m0_T mean(rendp_&methode.)=m_&methode._T
5798                                       var(rendp_n)=var0_T var(rendp_&methode.)=var_&methode._T
5799                                       mean(rendp_n_aj)=m0_aj_T mean(rendp_&methode._aj)=m_&methode._aj_T
5800                                       var(rendp_n_aj)=var0_aj_T var(rendp_&methode._aj)=var_&methode._aj_T;
5801  run;
5802
5803  data gain_&methode._T; set gain_T;
5804  gamma=3;
5805  v0_T=m0_T-(1/2)*gamma*var0_T;v_&methode._T=m_&methode._T-(1/2)*gamma*var_&methode._T;
5806  gain_&methode._T=(v_&methode._T-v0_T)*12;
5807  methode=&met.;label m0_T=m0_T;label var0_T=var0_T;
5808
5809  v0_aj_T=m0_aj_T-(1/2)*gamma*var0_aj_T;v_&methode._aj_T=m_&methode._aj_T-(1/2)*gamma*var_&methode._aj_T;
5810  gain_&methode._aj_T=(v_&methode._aj_T-v0_aj_T)*12;
5811  methode=&met.;label m0_aj_T=m0_aj_T;label var0_aj_T=var0_aj_T;
5812  run;
5813
5814  /*proc summary n nway data=previsions_&setvar.(where= (periode in ("1973-1995")));
5815  var rendp_n rendp_&methode. rendp_n_aj rendp_&methode._aj;
5816  output out=gain_S2 (drop=_type_ _freq_) mean(rendp_n)=m0_S2 mean(rendp_&methode.)=m_&methode._S2
5817                                       var(rendp_n)=var0_S2 var(rendp_&methode.)=var_&methode._S2
5818                                       mean(rendp_n_aj)=m0_aj_S2 mean(rendp_&methode._aj)=m_&methode._aj_S2
5819                                       var(rendp_n_aj)=var0_aj_S2 var(rendp_&methode._aj)=var_&methode._aj_S2;
5820  run;
5821
5822  data gain_&methode._S2; set gain_S2;
5823  gamma=3;
5824  v0_S2=m0_S2-(1/2)*gamma*var0_S2;v_&methode._S2=m_&methode._S2-(1/2)*gamma*var_&methode._S2;
5825  gain_&methode._S2=(v_&methode._S2-v0_S2)*12;
5826  methode=&met.;label m0_S2=m0_S2;label var0_S2=var0_S2;
5827
5828  v0_aj_S2=m0_aj_S2-(1/2)*gamma*var0_aj_S2;v_&methode._aj_S2=m_&methode._aj_S2-(1/2)*gamma*var_&methode._aj_S2;
5829  gain_&methode._aj_S2=(v_&methode._aj_S2-v0_aj_S2)*12;
5830  methode=&met.;label m0_aj_S2=m0_aj_S2;label var0_aj_S2=var0_aj_S2;
5831  run;
5832
5833  proc summary n nway data=previsions_&setvar.(where= (periode in ("1996-2018")));
5834  var rendp_n rendp_&methode. rendp_n_aj rendp_&methode._aj;
5835  output out=gain_S3 (drop=_type_ _freq_) mean(rendp_n)=m0_S3 mean(rendp_&methode.)=m_&methode._S3
5836                                       var(rendp_n)=var0_S3 var(rendp_&methode.)=var_&methode._S3
5837                                       mean(rendp_n_aj)=m0_aj_S3 mean(rendp_&methode._aj)=m_&methode._aj_S3
5838                                       var(rendp_n_aj)=var0_aj_S3 var(rendp_&methode._aj)=var_&methode._aj_S3;
5839  run;
5840
5841  data gain_&methode._S3; set gain_S3;
5842  gamma=3;
5843  v0_S3=m0_S3-(1/2)*gamma*var0_S3;v_&methode._S3=m_&methode._S3-(1/2)*gamma*var_&methode._S3;
5844  gain_&methode._S3=(v_&methode._S3-v0_S3)*12;
5845  methode=&met.;label m0_S3=m0_S3;label var0_S3=var0_S3;
5846
5847  v0_aj_S3=m0_aj_S3-(1/2)*gamma*var0_aj_S3;v_&methode._aj_S3=m_&methode._aj_S3-(1/2)*gamma*var_&methode._aj_S3;
5848  gain_&methode._aj_S3=(v_&methode._aj_S3-v0_aj_S3)*12;
5849  methode=&met.;label m0_aj_S3=m0_aj_S3;label var0_aj_S3=var0_aj_S3;*/
5850  run;
5851
5852  data r2gain_&methode.;
5853  merge coeff_det_&methode._&setvar._T t_&methode._T pvalue_&methode._T gain_&methode._T
5854        /*coeff_det_&methode._&setvar._S2 t_&methode._S2 pvalue_&methode._S2 gain_&methode._S2
5855        coeff_det_&methode._&setvar._S3 t_&methode._S3 pvalue_&methode._S3 gain_&methode._S3*/;
5856  by methode;
5857  run;
5858
5859  proc print data=r2gain_&methode.;
5860  RUN;
5861
5862  PROC EXPORT DATA=r2gain_&methode.
5863              OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_&methode._&setvar..xlsx"
5864              DBMS=XLSX REPLACE;
5865  RUN;
5866
5867  %mend r2gain;
5868
...
5899  /* Explications de la macro r2gain(methode, met, setvar, k)
5900  La macro r2gain(methode, met, setvar, k calcule les statistiques pour la signifiance du coefficient R2 OS
5901  et le profit generé pour la période totale et les deux sous-périodes.
5902
5903  methode: méthode de sélection du "combining weight" à utiliser, qui détermine la pondération à mettre sur chaque
5904           prévision individuelle dans leur combinaison;
5905  meth: identifiant associé à la méthode; l'identifiant doit concorder avec le choix de méthode;
5906  setvar: nom du set de variables à utiliser, soit CAN, US, BV ou ALL;
5907  k: nombre de variables dans le setvar choisi; le nombre doit concorder avec le choix de setvar (voir ci-dessous);
5908
5909  Cinq choix sont possibles pour methode: methode = mean, methode = mediane, methode = trim,
5910  methode = dmspe1, methode = dmspe09.
5911
5912  Le nombre de variables dans le set de variables doit concorder avec le choix du set de variables:
5913  Si le setvar est "US", alors k = 15;
5914  */
5915
5916  /* Voici les 5 principaux modèles de combinaison de prévisions OS utilisés. */
5917
5918  %r2gain(mean, 'mean', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var res2_mean res2_n_mean;
MPRINT(R2GAIN):   output out=coeff_det_mean_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data coeff_det_mean_US_T;
MPRINT(R2GAIN):  set coeff_det_mean_US_T;
MPRINT(R2GAIN):   r2_mean_CF_OS_T = 1-(res2_mean/res2_n_mean);
MPRINT(R2GAIN):   r2_adj_mean_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_mean_CF_OS_T);
MPRINT(R2GAIN):  methode='mean';
MPRINT(R2GAIN):   keep r2_mean_CF_OS_T r2_adj_mean_CF_OS_T methode;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   proc reg data=previsions_US(where= (periode in ("1973-1995" "1996-2018"))) outest=f_mean_stat_T edf outseb
tableout;
MPRINT(R2GAIN):   model f_mean= /MSE;
MPRINT(R2GAIN):  quit;
MPRINT(R2GAIN):   data t_mean_T;
MPRINT(R2GAIN):   set f_mean_stat_T;
MPRINT(R2GAIN):   if _type_="T";
MPRINT(R2GAIN):   keep intercept methode;
MPRINT(R2GAIN):  methode='mean';
MPRINT(R2GAIN):  rename intercept=tstat_T;
MPRINT(R2GAIN):  label intercept= tstat_T;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data pvalue_mean_T;
MPRINT(R2GAIN):   set f_mean_stat_T;
MPRINT(R2GAIN):   if _type_="PVALUE";
MPRINT(R2GAIN):   keep intercept methode;
MPRINT(R2GAIN):   methode='mean';
MPRINT(R2GAIN):  rename intercept=PVALUE_T;
MPRINT(R2GAIN):  label intercept= PVALUE_T;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data previsions_US;
MPRINT(R2GAIN):   merge previsions_US (in=a) varstock rend;
MPRINT(R2GAIN):   by obs;
MPRINT(R2GAIN):   if a;
MPRINT(R2GAIN):   gamma=3;
MPRINT(R2GAIN):   w0_n=(1/gamma)*(pred_n_oos/var_CRSPSPvw);
MPRINT(R2GAIN):   w_mean=(1/gamma)*(pred_mean/var_CRSPSPvw);
MPRINT(R2GAIN):   w0_n_aj=w0_n;
MPRINT(R2GAIN):   flag0=0;
MPRINT(R2GAIN):   if w0_n<0 then do;
MPRINT(R2GAIN):   w0_n_aj=0;
MPRINT(R2GAIN):   flag0=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w0_n>1.5 then do;
MPRINT(R2GAIN):   w0_n_aj=1.5;
MPRINT(R2GAIN):   flag0=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w0_n=. then w0_n_aj=.;
MPRINT(R2GAIN):   w_mean_aj=w_mean;
MPRINT(R2GAIN):   flag_mean=0;
MPRINT(R2GAIN):   if w_mean<0 then do;
MPRINT(R2GAIN):   w_mean_aj=0;
MPRINT(R2GAIN):  flag_mean=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w_mean>1.5 then do;
MPRINT(R2GAIN):   w_mean_aj=1.5;
MPRINT(R2GAIN):  flag_mean=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w_mean=. then w_mean_aj=.;
MPRINT(R2GAIN):   rendp_n = w0_n*CRSPSPvw + (1-w0_n)*Rfree;
MPRINT(R2GAIN):   rendp_mean = w_mean*rtsx+ (1-w_mean)*Rfree;
MPRINT(R2GAIN):   rendp_n_aj = w0_n_aj*CRSPSPvw + (1-w0_n_aj)*Rfree;
MPRINT(R2GAIN):   rendp_mean_aj = w_mean_aj*CRSPSPvw + (1-w_mean_aj)*Rfree;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var rendp_n rendp_mean rendp_n_aj rendp_mean_aj;
MPRINT(R2GAIN):   output out=gain_T (drop=_type_ _freq_) mean(rendp_n)=m0_T mean(rendp_mean)=m_mean_T var(rendp_n)=var0_T
var(rendp_mean)=var_mean_T mean(rendp_n_aj)=m0_aj_T mean(rendp_mean_aj)=m_mean_aj_T var(rendp_n_aj)=var0_aj_T
var(rendp_mean_aj)=var_mean_aj_T;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   data gain_mean_T;
MPRINT(R2GAIN):   set gain_T;
MPRINT(R2GAIN):   gamma=3;
MPRINT(R2GAIN):   v0_T=m0_T-(1/2)*gamma*var0_T;
MPRINT(R2GAIN):  v_mean_T=m_mean_T-(1/2)*gamma*var_mean_T;
MPRINT(R2GAIN):   gain_mean_T=(v_mean_T-v0_T)*12;
MPRINT(R2GAIN):   methode='mean';
MPRINT(R2GAIN):  label m0_T= m0_T;
MPRINT(R2GAIN):  label var0_T= var0_T;
MPRINT(R2GAIN):   v0_aj_T=m0_aj_T-(1/2)*gamma*var0_aj_T;
MPRINT(R2GAIN):  v_mean_aj_T=m_mean_aj_T-(1/2)*gamma*var_mean_aj_T;
MPRINT(R2GAIN):   gain_mean_aj_T=(v_mean_aj_T-v0_aj_T)*12;
MPRINT(R2GAIN):   methode='mean';
MPRINT(R2GAIN):  label m0_aj_T= m0_aj_T;
MPRINT(R2GAIN):  label var0_aj_T= var0_aj_T;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   data r2gain_mean;
MPRINT(R2GAIN):   merge coeff_det_mean_US_T t_mean_T pvalue_mean_T gain_mean_T ;
MPRINT(R2GAIN):   by methode;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   proc print data=r2gain_mean;
MPRINT(R2GAIN):   RUN;
MPRINT(R2GAIN):   PROC EXPORT DATA=r2gain_mean OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_mean_US.xlsx"
DBMS=XLSX REPLACE;
MPRINT(R2GAIN):   WXLX;
MPRINT(R2GAIN):   RUN;
5919  %r2gain(mediane, 'mediane', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var res2_mediane res2_n_mediane;
MPRINT(R2GAIN):   output out=coeff_det_mediane_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data coeff_det_mediane_US_T;
MPRINT(R2GAIN):  set coeff_det_mediane_US_T;
MPRINT(R2GAIN):   r2_mediane_CF_OS_T = 1-(res2_mediane/res2_n_mediane);
MPRINT(R2GAIN):   r2_adj_mediane_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_mediane_CF_OS_T);
MPRINT(R2GAIN):  methode='mediane';
MPRINT(R2GAIN):   keep r2_mediane_CF_OS_T r2_adj_mediane_CF_OS_T methode;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   proc reg data=previsions_US(where= (periode in ("1973-1995" "1996-2018"))) outest=f_mediane_stat_T edf
outseb tableout;
MPRINT(R2GAIN):   model f_mediane= /MSE;
MPRINT(R2GAIN):  quit;
MPRINT(R2GAIN):   data t_mediane_T;
MPRINT(R2GAIN):   set f_mediane_stat_T;
MPRINT(R2GAIN):   if _type_="T";
MPRINT(R2GAIN):   keep intercept methode;
MPRINT(R2GAIN):  methode='mediane';
MPRINT(R2GAIN):  rename intercept=tstat_T;
MPRINT(R2GAIN):  label intercept= tstat_T;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data pvalue_mediane_T;
MPRINT(R2GAIN):   set f_mediane_stat_T;
MPRINT(R2GAIN):   if _type_="PVALUE";
MPRINT(R2GAIN):   keep intercept methode;
MPRINT(R2GAIN):   methode='mediane';
MPRINT(R2GAIN):  rename intercept=PVALUE_T;
MPRINT(R2GAIN):  label intercept= PVALUE_T;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data previsions_US;
MPRINT(R2GAIN):   merge previsions_US (in=a) varstock rend;
MPRINT(R2GAIN):   by obs;
MPRINT(R2GAIN):   if a;
MPRINT(R2GAIN):   gamma=3;
MPRINT(R2GAIN):   w0_n=(1/gamma)*(pred_n_oos/var_CRSPSPvw);
MPRINT(R2GAIN):   w_mediane=(1/gamma)*(pred_mediane/var_CRSPSPvw);
MPRINT(R2GAIN):   w0_n_aj=w0_n;
MPRINT(R2GAIN):   flag0=0;
MPRINT(R2GAIN):   if w0_n<0 then do;
MPRINT(R2GAIN):   w0_n_aj=0;
MPRINT(R2GAIN):   flag0=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w0_n>1.5 then do;
MPRINT(R2GAIN):   w0_n_aj=1.5;
MPRINT(R2GAIN):   flag0=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w0_n=. then w0_n_aj=.;
MPRINT(R2GAIN):   w_mediane_aj=w_mediane;
MPRINT(R2GAIN):   flag_mediane=0;
MPRINT(R2GAIN):   if w_mediane<0 then do;
MPRINT(R2GAIN):   w_mediane_aj=0;
MPRINT(R2GAIN):  flag_mediane=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w_mediane>1.5 then do;
MPRINT(R2GAIN):   w_mediane_aj=1.5;
MPRINT(R2GAIN):  flag_mediane=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w_mediane=. then w_mediane_aj=.;
MPRINT(R2GAIN):   rendp_n = w0_n*CRSPSPvw + (1-w0_n)*Rfree;
MPRINT(R2GAIN):   rendp_mediane = w_mediane*rtsx+ (1-w_mediane)*Rfree;
MPRINT(R2GAIN):   rendp_n_aj = w0_n_aj*CRSPSPvw + (1-w0_n_aj)*Rfree;
MPRINT(R2GAIN):   rendp_mediane_aj = w_mediane_aj*CRSPSPvw + (1-w_mediane_aj)*Rfree;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var rendp_n rendp_mediane rendp_n_aj rendp_mediane_aj;
MPRINT(R2GAIN):   output out=gain_T (drop=_type_ _freq_) mean(rendp_n)=m0_T mean(rendp_mediane)=m_mediane_T
var(rendp_n)=var0_T var(rendp_mediane)=var_mediane_T mean(rendp_n_aj)=m0_aj_T mean(rendp_mediane_aj)=m_mediane_aj_T
var(rendp_n_aj)=var0_aj_T var(rendp_mediane_aj)=var_mediane_aj_T;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   data gain_mediane_T;
MPRINT(R2GAIN):   set gain_T;
MPRINT(R2GAIN):   gamma=3;
MPRINT(R2GAIN):   v0_T=m0_T-(1/2)*gamma*var0_T;
MPRINT(R2GAIN):  v_mediane_T=m_mediane_T-(1/2)*gamma*var_mediane_T;
MPRINT(R2GAIN):   gain_mediane_T=(v_mediane_T-v0_T)*12;
MPRINT(R2GAIN):   methode='mediane';
MPRINT(R2GAIN):  label m0_T= m0_T;
MPRINT(R2GAIN):  label var0_T= var0_T;
MPRINT(R2GAIN):   v0_aj_T=m0_aj_T-(1/2)*gamma*var0_aj_T;
MPRINT(R2GAIN):  v_mediane_aj_T=m_mediane_aj_T-(1/2)*gamma*var_mediane_aj_T;
MPRINT(R2GAIN):   gain_mediane_aj_T=(v_mediane_aj_T-v0_aj_T)*12;
MPRINT(R2GAIN):   methode='mediane';
MPRINT(R2GAIN):  label m0_aj_T= m0_aj_T;
MPRINT(R2GAIN):  label var0_aj_T= var0_aj_T;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   data r2gain_mediane;
MPRINT(R2GAIN):   merge coeff_det_mediane_US_T t_mediane_T pvalue_mediane_T gain_mediane_T ;
MPRINT(R2GAIN):   by methode;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   proc print data=r2gain_mediane;
MPRINT(R2GAIN):   RUN;
MPRINT(R2GAIN):   PROC EXPORT DATA=r2gain_mediane OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_mediane_US.xlsx"
DBMS=XLSX REPLACE;
MPRINT(R2GAIN):   WXLX;
MPRINT(R2GAIN):   RUN;
5920  %r2gain(trim, 'trim', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var res2_trim res2_n_trim;
MPRINT(R2GAIN):   output out=coeff_det_trim_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data coeff_det_trim_US_T;
MPRINT(R2GAIN):  set coeff_det_trim_US_T;
MPRINT(R2GAIN):   r2_trim_CF_OS_T = 1-(res2_trim/res2_n_trim);
MPRINT(R2GAIN):   r2_adj_trim_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_trim_CF_OS_T);
MPRINT(R2GAIN):  methode='trim';
MPRINT(R2GAIN):   keep r2_trim_CF_OS_T r2_adj_trim_CF_OS_T methode;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   proc reg data=previsions_US(where= (periode in ("1973-1995" "1996-2018"))) outest=f_trim_stat_T edf outseb
tableout;
MPRINT(R2GAIN):   model f_trim= /MSE;
MPRINT(R2GAIN):  quit;
MPRINT(R2GAIN):   data t_trim_T;
MPRINT(R2GAIN):   set f_trim_stat_T;
MPRINT(R2GAIN):   if _type_="T";
MPRINT(R2GAIN):   keep intercept methode;
MPRINT(R2GAIN):  methode='trim';
MPRINT(R2GAIN):  rename intercept=tstat_T;
MPRINT(R2GAIN):  label intercept= tstat_T;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data pvalue_trim_T;
MPRINT(R2GAIN):   set f_trim_stat_T;
MPRINT(R2GAIN):   if _type_="PVALUE";
MPRINT(R2GAIN):   keep intercept methode;
MPRINT(R2GAIN):   methode='trim';
MPRINT(R2GAIN):  rename intercept=PVALUE_T;
MPRINT(R2GAIN):  label intercept= PVALUE_T;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data previsions_US;
MPRINT(R2GAIN):   merge previsions_US (in=a) varstock rend;
MPRINT(R2GAIN):   by obs;
MPRINT(R2GAIN):   if a;
MPRINT(R2GAIN):   gamma=3;
MPRINT(R2GAIN):   w0_n=(1/gamma)*(pred_n_oos/var_CRSPSPvw);
MPRINT(R2GAIN):   w_trim=(1/gamma)*(pred_trim/var_CRSPSPvw);
MPRINT(R2GAIN):   w0_n_aj=w0_n;
MPRINT(R2GAIN):   flag0=0;
MPRINT(R2GAIN):   if w0_n<0 then do;
MPRINT(R2GAIN):   w0_n_aj=0;
MPRINT(R2GAIN):   flag0=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w0_n>1.5 then do;
MPRINT(R2GAIN):   w0_n_aj=1.5;
MPRINT(R2GAIN):   flag0=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w0_n=. then w0_n_aj=.;
MPRINT(R2GAIN):   w_trim_aj=w_trim;
MPRINT(R2GAIN):   flag_trim=0;
MPRINT(R2GAIN):   if w_trim<0 then do;
MPRINT(R2GAIN):   w_trim_aj=0;
MPRINT(R2GAIN):  flag_trim=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w_trim>1.5 then do;
MPRINT(R2GAIN):   w_trim_aj=1.5;
MPRINT(R2GAIN):  flag_trim=1;
MPRINT(R2GAIN):   end;
MPRINT(R2GAIN):   if w_trim=. then w_trim_aj=.;
MPRINT(R2GAIN):   rendp_n = w0_n*CRSPSPvw + (1-w0_n)*Rfree;
MPRINT(R2GAIN):   rendp_trim = w_trim*rtsx+ (1-w_trim)*Rfree;
MPRINT(R2GAIN):   rendp_n_aj = w0_n_aj*CRSPSPvw + (1-w0_n_aj)*Rfree;
MPRINT(R2GAIN):   rendp_trim_aj = w_trim_aj*CRSPSPvw + (1-w_trim_aj)*Rfree;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var rendp_n rendp_trim rendp_n_aj rendp_trim_aj;
MPRINT(R2GAIN):   output out=gain_T (drop=_type_ _freq_) mean(rendp_n)=m0_T mean(rendp_trim)=m_trim_T var(rendp_n)=var0_T
var(rendp_trim)=var_trim_T mean(rendp_n_aj)=m0_aj_T mean(rendp_trim_aj)=m_trim_aj_T var(rendp_n_aj)=var0_aj_T
var(rendp_trim_aj)=var_trim_aj_T;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   data gain_trim_T;
MPRINT(R2GAIN):   set gain_T;
MPRINT(R2GAIN):   gamma=3;
MPRINT(R2GAIN):   v0_T=m0_T-(1/2)*gamma*var0_T;
MPRINT(R2GAIN):  v_trim_T=m_trim_T-(1/2)*gamma*var_trim_T;
MPRINT(R2GAIN):   gain_trim_T=(v_trim_T-v0_T)*12;
MPRINT(R2GAIN):   methode='trim';
MPRINT(R2GAIN):  label m0_T= m0_T;
MPRINT(R2GAIN):  label var0_T= var0_T;
MPRINT(R2GAIN):   v0_aj_T=m0_aj_T-(1/2)*gamma*var0_aj_T;
MPRINT(R2GAIN):  v_trim_aj_T=m_trim_aj_T-(1/2)*gamma*var_trim_aj_T;
MPRINT(R2GAIN):   gain_trim_aj_T=(v_trim_aj_T-v0_aj_T)*12;
MPRINT(R2GAIN):   methode='trim';
MPRINT(R2GAIN):  label m0_aj_T= m0_aj_T;
MPRINT(R2GAIN):  label var0_aj_T= var0_aj_T;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   data r2gain_trim;
MPRINT(R2GAIN):   merge coeff_det_trim_US_T t_trim_T pvalue_trim_T gain_trim_T ;
MPRINT(R2GAIN):   by methode;
MPRINT(R2GAIN):   run;
MPRINT(R2GAIN):   proc print data=r2gain_trim;
MPRINT(R2GAIN):   RUN;
MPRINT(R2GAIN):   PROC EXPORT DATA=r2gain_trim OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx"
DBMS=XLSX REPLACE;
MPRINT(R2GAIN):   WXLX;
MPRINT(R2GAIN):   RUN;
5921  %r2gain(dmspe09,'dmspe09', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var res2_dmspe09 res2_n_dmspe09;
MPRINT(R2GAIN):   output out=coeff_det_dmspe09_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):  set coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):   r2_dmspe09_CF_OS_T = 1-(res2_dmspe09/res2_n_dmspe09);
MPRINT(R2GAIN):   r2_adj_dmspe09_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_dmspe09_CF_OS_T);
MPRINT(R2GAIN):  methode='dmspe09';
MPRINT(R2GAIN):   keep r2_dmspe09_CF_OS_T r2_adj_dmspe09_CF_OS_T methode;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   proc reg data=previsions_US(where= (periode in ("1973-1995" "1996-2018"))) outest=f_dmspe09_stat_T edf
outseb tableout;
MPRINT(R2GAIN):   model f_dmspe09= /MSE;
MPRINT(R2GAIN):  quit;
ERROR: No valid observations are found.

 

 

Ps: As the message cannot exceed 200,000 characters, I had to cut some lines from 5869 to 5898.

11 REPLIES 11
Reeza
Super User
Do you have nonotes turned on? You should be seeing notes that shows how many records are in each step and I'm not seeing that in your log. I'd bet a filter is specified incorrectly somewhere.
pmorel3
Obsidian | Level 7

Nonotes is turned off.

 

"options mprint;
/*options nonotes nomprint;*/"

 

Do you mean a filter relative to "dmspe09" ?

Shmuel
Garnet | Level 18

Focus on last part:

 

5921  %r2gain(dmspe09,'dmspe09', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US(where= (periode in ("1973-1995" "1996-2018")));
MPRINT(R2GAIN):   var res2_dmspe09 res2_n_dmspe09;
MPRINT(R2GAIN):   output out=coeff_det_dmspe09_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   data coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):  set coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):   r2_dmspe09_CF_OS_T = 1-(res2_dmspe09/res2_n_dmspe09);
MPRINT(R2GAIN):   r2_adj_dmspe09_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_dmspe09_CF_OS_T);
MPRINT(R2GAIN):  methode='dmspe09';
MPRINT(R2GAIN):   keep r2_dmspe09_CF_OS_T r2_adj_dmspe09_CF_OS_T methode;
MPRINT(R2GAIN):  run;
MPRINT(R2GAIN):   proc reg data=previsions_US(where= (periode in ("1973-1995" "1996-2018"))) outest=f_dmspe09_stat_T edf
outseb tableout;
MPRINT(R2GAIN):   model f_dmspe09= /MSE;
MPRINT(R2GAIN):  quit;
ERROR: No valid observations are found.
 

the message error relates to proc reg. Check dataset previsions_US - are there observations with the required periode ?

Is there a variable f_dmspe09 and is it numeric as required ?

 

pmorel3
Obsidian | Level 7

Thank you Shmuel for your answer.

To make it simple, I cancelled (blocked) all the period subdivisions and tried to run my codes for only the 6 last observations but I have the same results in dataset previsions_US : there are always no values in pred_dmspe09, res2_dmspe09, f_dmspe09, res2_n_dmspe09 variables (columns). However, I get numeric values for other columns. 

ballardw
Super User

@pmorel3 wrote:

Nonotes is turned off.

 

"options mprint;
/*options nonotes nomprint;*/"

 

Do you mean a filter relative to "dmspe09" ?


If you had previous submitted

options nonotes nomprint;

prior to commenting out that line then using the Options mprint then NONOTES is ON (or Notes if Off if your prefer). You did not turn Notes back on.

It is a good idea when you start getting errors to make sure that NOTES is on because things like empty data sets or uninitialized variables that cause serious problems later in the code don't show the information needed to find quite where things may have started to go wrong.

pmorel3
Obsidian | Level 7

Thanks ballardw.

pmorel3
Obsidian | Level 7
NOTE: There were 1 observations read from the data set WORK.R2GAIN_TRIM.
NOTE: PROCEDURE PRINT a utilisé (Durée totale du traitement) :
      real time           0.01 seconds
      cpu time            0.00 seconds


MPRINT(R2GAIN):   PROC EXPORT DATA=r2gain_trim OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx"
DBMS=XLSX REPLACE;
MPRINT(R2GAIN):   WXLX;
MPRINT(R2GAIN):   RUN;

NOTE: The export data set has 1 observations and 20 variables.
NOTE: "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT a utilisé (Durée totale du traitement) :
      real time           0.04 seconds
      cpu time            0.01 seconds


8557  %r2gain(dmspe09,'dmspe09', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US;
MPRINT(R2GAIN):   var res2_dmspe09 res2_n_dmspe09;
MPRINT(R2GAIN):   output out=coeff_det_dmspe09_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;

NOTE: There were 6 observations read from the data set WORK.PREVISIONS_US.
NOTE: The data set WORK.COEFF_DET_DMSPE09_US_T has 1 observations and 3 variables.
NOTE: PROCEDURE SUMMARY a utilisé (Durée totale du traitement) :
      real time           0.00 seconds
      cpu time            0.00 seconds


MPRINT(R2GAIN):   data coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):  set coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):   r2_dmspe09_CF_OS_T = 1-(res2_dmspe09/res2_n_dmspe09);
MPRINT(R2GAIN):   r2_adj_dmspe09_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_dmspe09_CF_OS_T);
MPRINT(R2GAIN):  methode='dmspe09';
MPRINT(R2GAIN):   keep r2_dmspe09_CF_OS_T r2_adj_dmspe09_CF_OS_T methode;
MPRINT(R2GAIN):  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 à 2:16   1 à 2:96
NOTE: There were 1 observations read from the data set WORK.COEFF_DET_DMSPE09_US_T.
NOTE: The data set WORK.COEFF_DET_DMSPE09_US_T has 1 observations and 3 variables.
NOTE: DATA statement a utilisé (Durée totale du traitement) :
      real time           0.00 seconds
      cpu time            0.01 seconds


MPRINT(R2GAIN):   proc reg data=previsions_US outest=f_dmspe09_stat_T edf outseb tableout;
MPRINT(R2GAIN):   model f_dmspe09= /MSE;
MPRINT(R2GAIN):  quit;

ERROR: No valid observations are found.
NOTE: The data set WORK.F_DMSPE09_STAT_T has 0 observations and 11 variables.
NOTE: PROCEDURE REG a utilisé (Durée totale du traitement) :
      real time           0.04 seconds
      cpu time            0.03 seconds


 This is an extract of the log with notes. If you want more lines, please let me know !

Thanks !

PaigeMiller
Diamond | Level 26

Your problem with NO VALID Observations is the same as in your other thread. The solution is the same.

 

If you use OPTIONS NONOTES; then notes stay off until you turn it on with Options NOTES; 

 

Commenting out the option does not reset anything.

 

Also in your other thread, I asked you to show us about 50 rows before the error, not 500 rows which is not helpful. Please cut down on the number of rows you are posting to the RELEVANT parts of the log.

--
Paige Miller
pmorel3
Obsidian | Level 7
NOTE: There were 1 observations read from the data set WORK.R2GAIN_TRIM.
NOTE: PROCEDURE PRINT a utilisé (Durée totale du traitement) :
      real time           0.01 seconds
      cpu time            0.00 seconds


MPRINT(R2GAIN):   PROC EXPORT DATA=r2gain_trim OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx"
DBMS=XLSX REPLACE;
MPRINT(R2GAIN):   WXLX;
MPRINT(R2GAIN):   RUN;

NOTE: The export data set has 1 observations and 20 variables.
NOTE: "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT a utilisé (Durée totale du traitement) :
      real time           0.04 seconds
      cpu time            0.01 seconds


8557  %r2gain(dmspe09,'dmspe09', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US;
MPRINT(R2GAIN):   var res2_dmspe09 res2_n_dmspe09;
MPRINT(R2GAIN):   output out=coeff_det_dmspe09_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;

NOTE: There were 6 observations read from the data set WORK.PREVISIONS_US.
NOTE: The data set WORK.COEFF_DET_DMSPE09_US_T has 1 observations and 3 variables.
NOTE: PROCEDURE SUMMARY a utilisé (Durée totale du traitement) :
      real time           0.00 seconds
      cpu time            0.00 seconds


MPRINT(R2GAIN):   data coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):  set coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):   r2_dmspe09_CF_OS_T = 1-(res2_dmspe09/res2_n_dmspe09);
MPRINT(R2GAIN):   r2_adj_dmspe09_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_dmspe09_CF_OS_T);
MPRINT(R2GAIN):  methode='dmspe09';
MPRINT(R2GAIN):   keep r2_dmspe09_CF_OS_T r2_adj_dmspe09_CF_OS_T methode;
MPRINT(R2GAIN):  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 à 2:16   1 à 2:96
NOTE: There were 1 observations read from the data set WORK.COEFF_DET_DMSPE09_US_T.
NOTE: The data set WORK.COEFF_DET_DMSPE09_US_T has 1 observations and 3 variables.
NOTE: DATA statement a utilisé (Durée totale du traitement) :
      real time           0.00 seconds
      cpu time            0.01 seconds


MPRINT(R2GAIN):   proc reg data=previsions_US outest=f_dmspe09_stat_T edf outseb tableout;
MPRINT(R2GAIN):   model f_dmspe09= /MSE;
MPRINT(R2GAIN):  quit;

ERROR: No valid observations are found.
NOTE: The data set WORK.F_DMSPE09_STAT_T has 0 observations and 11 variables.
NOTE: PROCEDURE REG a utilisé (Durée totale du traitement) :
      real time           0.04 seconds
      cpu time            0.03 seconds


This is an extract of my log with only 50 lines before the error message.

 As you had no way of knowing what is actually in data set PREVISIONS_US, I decided to give you more details.

Reeza
Super User

Look at the model statement. What happens if they left hand side is missing and you have a single observation? You can’t run a regression. 

But your ‘regression’ is just a means calculation so not even sure why you’re doing it. 

This replicates the issue.

Data class;
Set sashelp.class (obs=1);
Test =.;

Proc reg data =class;
Model test = /mse;
Run;quit;

@pmorel3 wrote:
NOTE: There were 1 observations read from the data set WORK.R2GAIN_TRIM.
NOTE: PROCEDURE PRINT a utilisé (Durée totale du traitement) :
      real time           0.01 seconds
      cpu time            0.00 seconds


MPRINT(R2GAIN):   PROC EXPORT DATA=r2gain_trim OUTFILE= "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx"
DBMS=XLSX REPLACE;
MPRINT(R2GAIN):   WXLX;
MPRINT(R2GAIN):   RUN;

NOTE: The export data set has 1 observations and 20 variables.
NOTE: "C:\Users\NPMOR\Desktop\Pas\results\CF_OS_r2gain_trim_US.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT a utilisé (Durée totale du traitement) :
      real time           0.04 seconds
      cpu time            0.01 seconds


8557  %r2gain(dmspe09,'dmspe09', US, 14);
MPRINT(R2GAIN):   proc summary n nway data=previsions_US;
MPRINT(R2GAIN):   var res2_dmspe09 res2_n_dmspe09;
MPRINT(R2GAIN):   output out=coeff_det_dmspe09_US_T(drop=_type_) sum=;
MPRINT(R2GAIN):  run;

NOTE: There were 6 observations read from the data set WORK.PREVISIONS_US.
NOTE: The data set WORK.COEFF_DET_DMSPE09_US_T has 1 observations and 3 variables.
NOTE: PROCEDURE SUMMARY a utilisé (Durée totale du traitement) :
      real time           0.00 seconds
      cpu time            0.00 seconds


MPRINT(R2GAIN):   data coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):  set coeff_det_dmspe09_US_T;
MPRINT(R2GAIN):   r2_dmspe09_CF_OS_T = 1-(res2_dmspe09/res2_n_dmspe09);
MPRINT(R2GAIN):   r2_adj_dmspe09_CF_OS_T = 1-(_freq_-1)/(_freq_- 1 - 14)*(1-r2_dmspe09_CF_OS_T);
MPRINT(R2GAIN):  methode='dmspe09';
MPRINT(R2GAIN):   keep r2_dmspe09_CF_OS_T r2_adj_dmspe09_CF_OS_T methode;
MPRINT(R2GAIN):  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 à 2:16   1 à 2:96
NOTE: There were 1 observations read from the data set WORK.COEFF_DET_DMSPE09_US_T.
NOTE: The data set WORK.COEFF_DET_DMSPE09_US_T has 1 observations and 3 variables.
NOTE: DATA statement a utilisé (Durée totale du traitement) :
      real time           0.00 seconds
      cpu time            0.01 seconds


MPRINT(R2GAIN):   proc reg data=previsions_US outest=f_dmspe09_stat_T edf outseb tableout;
MPRINT(R2GAIN):   model f_dmspe09= /MSE;
MPRINT(R2GAIN):  quit;

ERROR: No valid observations are found.
NOTE: The data set WORK.F_DMSPE09_STAT_T has 0 observations and 11 variables.
NOTE: PROCEDURE REG a utilisé (Durée totale du traitement) :
      real time           0.04 seconds
      cpu time            0.03 seconds


This is an extract of my log with only 50 lines before the error message.

 As you had no way of knowing what is actually in data set PREVISIONS_US, I decided to give you more details.


 

PaigeMiller
Diamond | Level 26


 As you had no way of knowing what is actually in data set PREVISIONS_US, I decided to give you more details.

 

This was all answered in your other thread.

 

And actually I did NOT ask you to give me more details, you have misunderstood. I asked you to look at the data set PREVISIONS_US with your own eyes (in other words, I don't want to look at it as you can do that yourself) and see what is in there. Once you know what is in there, then you will know what to do next.

 

Looking at the data yourself to try to figure out the error is the very first step people should follow when debugging a SAS programming issue.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1807 views
  • 5 likes
  • 5 in conversation