Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 5.18 KB | None | 0 0
  1. libname sasts '/home/klv3840/sasuser.v94';
  2.  
  3. * Opgave 1;
  4. * Opgave 1a;
  5. * ugevariation;
  6. PROC TIMESERIES data=sasts.udlaan_6_8 out=chrhavn;
  7. id date interval=day accumulate=total setmissing=missing;
  8. var d;
  9. run;
  10. * Simpelt plot;
  11. PROC SGPLOT data=chrhavn;
  12. series x=date y=d/markers;
  13. run;
  14.  
  15. * Plot over ugedagsvariation;
  16. data ugevar;
  17. set chrhavn;
  18. week=week(date);
  19. week_day=weekday(date);
  20. run;
  21. PROC SGPLOT data=ugevar;
  22. series x=week_day y=d/group=week markers;
  23. run;
  24.  
  25. * døgnsvariation;
  26. PROC TIMESERIES data=sasts.udlaan_6_8 out=chrhavn2;
  27. id date_time interval=hour accumulate=total setmissing=0;
  28. var d;
  29. run;
  30.  
  31. data dognvar;
  32. set chrhavn2;
  33. hour=hour(date_time);
  34. week=week(date);
  35. week_day=weekday(date_time);
  36. run;
  37. PROC SGPLOT data=dognvar;
  38. series x=hour y=d/markers;
  39. run;
  40.  
  41. * Opgave 1b;
  42. PROC TIMESERIES data=sasts.udlaan_6_8 out=chrhavn3;
  43. id date_time interval=hour6 accumulate=average setmissing=missing;
  44. var alder;
  45. run;
  46.  
  47. * UCM model med cycles;
  48. PROC UCM data=chrhavn3 plots=all;
  49. id date_time interval=hour6;
  50. model alder;
  51. level plot=smooth checkbreak;
  52. slope plot=smooth;
  53. cycle period=4 rho=1 variance=0 noest=(rho period variance);
  54. cycle period=28 rho=1 variance=0 noest=(rho period variance);
  55. outlier ;
  56. estimate plot=(panel);
  57. forecast lead=56 plot=forecasts;
  58. run;
  59. ods graphics off;
  60.  
  61. * UCM model med seasonal dummies;
  62. ods graphics;
  63. PROC UCM data=chrhavn3 plots=all;
  64. id date_time interval=hour6;
  65. model alder;
  66. level plot=smooth checkbreak;
  67. slope plot=smooth;
  68. season length=4;
  69. season length=28;
  70. outlier ;
  71. estimate plot=(panel);
  72. forecast lead=56 plot=forecasts;
  73. run;
  74. ods graphics off;
  75.  
  76. * UCM model med harmonics;
  77. ods graphics;
  78. PROC UCM data=chrhavn3 plots=all;
  79. id date_time interval=hour6;
  80. model alder;
  81. level plot=smooth checkbreak;
  82. slope plot=smooth;
  83. season length=4 type=trig print=harmonics;
  84. season length=28 type=trig print=harmonics;
  85. outlier ;
  86. estimate plot=(panel);
  87. forecast lead=56 plot=forecasts;
  88. run;
  89. ods graphics off;
  90.  
  91. * UCM model med dummy variabel for døgnvariation;
  92. PROC UCM data=chrhavn3 plots=all;
  93. id date_time interval=hour6;
  94. model alder;
  95. level plot=smooth checkbreak;
  96. slope var=0 noest;
  97. season length=4 type=trig print=harmonics;
  98. outlier ;
  99. estimate plot=(panel);
  100. forecast lead=56 plot=forecasts;
  101. run;
  102. ods graphics off;
  103.  
  104. * UCM model med dummy variabel for ugdagsvariation;
  105. PROC UCM data=chrhavn3 plots=all;
  106. id date_time interval=hour6;
  107. model alder;
  108. level plot=smooth checkbreak;
  109. slope var=0 noest;
  110. season length=28 type=trig print=harmonics;
  111. outlier ;
  112. estimate plot=(panel);
  113. forecast lead=56 plot=forecasts;
  114. run;
  115. ods graphics off;
  116.  
  117.  
  118. * Opgave 2;
  119. * Opgave 2a;
  120. * Laver mig nyt datasæt;
  121. data norge1;
  122. set sasts.udenrigshandel;
  123. keep date;
  124. keep s114;
  125. keep Eksport_i_alt;
  126. run;
  127.  
  128. * Plot data;
  129. PROC SGPLOT data=norge1;
  130. series x=date y=s114/markers;
  131. run;
  132.  
  133. * Foretag sæson udrensning;
  134. PROC X12 data=norge1 date=date;
  135. var s114;
  136. x11;
  137. output out=out_eksport a1 d10 d11 d12 d13 c17; run;
  138.  
  139. * Plotter resultatet;
  140. PROC SGPLOT data=out_eksport;
  141. series x=date y=s114_A1/markers;
  142. series x=date y=s114_D11/markers;
  143. run;
  144. PROC SGPLOT data=out_eksport;
  145. series x=date y=s114_D10/markers;
  146. run;
  147. PROC SGPLOT data=out_eksport;
  148. series x=date y=s114_D12/markers;
  149. run;
  150. PROC SGPLOT data=out_eksport;
  151. series x=date y=s114_D13/markers;
  152. run;
  153.  
  154. * Opgave 2b;
  155. PROC X12 data=norge1 date=date;
  156. var s114;
  157. transform function=log;
  158. automdl;
  159. regression predefined=(td easter(1));
  160. outlier;
  161. forecast lead=36;
  162. ods output ForecastCL=predicted;
  163. x11;
  164. output out=norge2 a1 d10 d11 d12 d13;
  165. run;
  166.  
  167. * Opgave 2c;
  168. * simple;
  169. PROC ESM data=norge1 print=estimates
  170. plot=(MODELFORECASTS ERRORS) lead=36;
  171. id date interval=month;
  172. forecast s114/method=simple;
  173. run;
  174. * double;
  175. PROC ESM data=norge1 print=estimates
  176. plot=(MODELFORECASTS ERRORS) lead=36;
  177. id date interval=month;
  178. forecast s114/method=double;
  179. run;
  180. * winters;
  181. PROC ESM data=norge1 print=estimates
  182. plot=(MODELFORECASTS ERRORS) lead=36;
  183. id date interval=month;
  184. forecast s114/method=winthers;
  185. run;
  186.  
  187. * Opgave 2d;
  188. * varierende trend;
  189. PROC UCM data=norge1;
  190. id date interval=month;
  191. model s114;
  192. level plot=smooth checkbreak;
  193. slope plot=smooth ;
  194. season length=12 plot=(smooth s_annual);
  195. outlier;
  196. estimate plot=(panel);
  197. forecast lead=36 plot=forecasts alpha=0.1;
  198. run;
  199. * fast trend;
  200. PROC UCM data=norge1;
  201. id date interval=month;
  202. model s114;
  203. level plot=smooth checkbreak;
  204. slope plot=smooth var=0 noest;
  205. season length=12 plot=(smooth s_annual);
  206. outlier;
  207. estimate plot=(panel);
  208. forecast lead=36 plot=forecasts alpha=0.1;
  209. run;
  210.  
  211. * Opgave 2e;
  212. * plot de to tidsserier;
  213. PROC SGPLOT data=norge1;
  214. series x=date y=s114/markers;
  215. series x=date y=Eksport_i_alt/markers y2axis;
  216. run;
  217.  
  218. * fast regressionskoefficient;
  219. PROC UCM data=norge1;
  220. id date interval=month;
  221. model s114 = Eksport_i_alt;
  222. level plot=smooth;
  223. slope plot=smooth var=0 noest; season length=12 plot=smooth;
  224. outlier ;
  225. estimate plot=all;
  226. forecast lead=36 plot=all alpha=0.1;
  227. run;
  228.  
  229. * varierende regressionskoefficient;
  230. PROC UCM data=norge1;
  231. id date interval=month;
  232. model s114;
  233. randomreg Eksport_i_alt/plot=smooth;
  234. level plot=smooth var=0 noest;
  235. season length=12 plot=smooth;
  236. outlier;
  237. estimate plot=all;
  238. forecast lead=36 plot=all alpha=0.1;
  239. run;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement