Advertisement
Guest User

Untitled

a guest
Sep 24th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.53 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. proc sgplot data=WTPmax;
  53. vbar xgroup / stat=percent barwidth=1 limits=both;
  54. format xgroup groupformat.;
  55. run;
  56.  
  57. proc freq data=WTPmax;
  58. /weight;
  59. by xgroup;
  60. 1*2*3*4*5*6*7;
  61. output out=percent;
  62. run;
  63.  
  64. proc sort data=WTPmax;
  65.       by xgroup;
  66.    run;
  67.    
  68.    ods graphics on;
  69.    proc freq data=WTPmax order=data;
  70.       tables xgroup / chisq testp=(0.0258 0.09685 0.13578 0.14344 0.20106 0.27451 0.12268)
  71.                     plots(only)=deviationplot(type=dot);
  72.       weight percent;
  73.       by xgroup;
  74.       title 'Chi square of theoretical distribution';
  75.    run;
  76.    ods graphics off;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement