Advertisement
Guest User

Untitled

a guest
Sep 25th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.18 KB | None | 0 0
  1. data loopex4;
  2. seed=11023;
  3.     do stickprov=1 to 1000;
  4.         do obs=1 to 5;
  5.         x=100*ranuni(seed);
  6.         output;
  7.         end;
  8.     end;
  9. drop obs;
  10. drop seed;
  11. run;
  12.  
  13. proc summary data=loopex4;
  14.     by stickprov;
  15.     id x;
  16.     output out=WTPmax (drop= _TYPE_ _FREQ_ ) max(x)=;
  17. run;
  18.  
  19. data WTPmax;
  20. set WTPmax;
  21.     e=(5/((5+1))*100);
  22.     std=SQRT((5*(100*100))/(((5+1)*(5+1))*(5+2)));
  23.     xstd=(x-e)/std;
  24. run;
  25.  
  26. data WTPmax;
  27. set WTPmax;
  28.     if xstd < -2.5 then xgroup=1;
  29.     if xstd < -1.25 & xstd > -2.5 then xgroup=2;
  30.     if xstd < -0.5 & xstd > -1.25 then xgroup=3;
  31.     if xstd < 0 & xstd > -0.5 then xgroup=4;
  32.     if xstd < 0.5 & xstd > 0 then xgroup=5;
  33.     if xstd < 1 & xstd > 0.5 then xgroup=6;
  34.     if xstd > 1 then xgroup=7;
  35. run;
  36.  
  37. proc print data=WTPmax;
  38. run;
  39.  
  40. proc format;
  41. value groupformat
  42.     1 = '<-2.5'
  43.     2 = '-2.5 - -1.25'
  44.     3 = '-1.25 - -0.5'
  45.     4 = '-0.5 - 0'
  46.     5 = '0 - 0.5'
  47.     6 = '0.5 - 1'
  48.     7 = '>1'
  49.     ;
  50. run;
  51.  
  52.  
  53.  
  54. proc sort data=WTPmax;
  55. by xgroup;
  56. run;
  57.    
  58. ods graphics on;
  59. proc freq data=WTPmax order=data;
  60.     tables xgroup / nocum chisq testp=(0.0258 0.09685 0.13578 0.14344 0.20106 0.27451 0.12268)
  61.     plots(only)=deviationplot(type=dot);
  62.     title 'Chi square of theoretical distribution';
  63. run;
  64. ods graphics off;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement