Advertisement
Womee

Untitled

Jan 25th, 2020
2,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.38 KB | None | 0 0
  1. data z1;
  2.     put _ALL_;
  3.     set sashelp.class;
  4.     put _ALL_;
  5.         col1 = weight / 2;
  6.         put _ALL_;
  7. run;
  8.  
  9. data z2;
  10.     set sashelp.cars end = koniec;
  11.     *retain total 0; /* zapamietaj total = 0*/
  12.     *total = total + invoice;
  13.  
  14.     total + invoice;
  15.     keep total;
  16.     if koniec then output;
  17. run;
  18.  
  19. *przetwarzanie w grupach
  20. zlicz liczbê aut dla każdej marki;
  21.  
  22. proc sort data = sashelp.cars out = cars;
  23.     by make;
  24. run;
  25.  
  26. data z3;
  27.     set cars;
  28.     by make;
  29.     col1 = first.make;
  30.     col2 = last.make;
  31. run;
  32.  
  33. data z4;
  34.     set sashelp.cars;
  35.     by make;
  36.     if first.make then do
  37.         licznik = 0;
  38.         suma = 0;
  39.     end;
  40.     licznik + 1;
  41.     suma + invoice;
  42.     if last.make then output;
  43.     keep make licznik suma;
  44. run;
  45.  
  46. *na podstawie sashelp.air zliczyĉ przewozy w latach;
  47. data z5;
  48.     set sashelp.air;
  49.     rok = year(date);
  50. run;
  51.  
  52. data z6;
  53.     set z5;
  54.     by rok;
  55.     if first.rok then suma = 0;
  56.     suma + air;
  57.     if last.rok then output;
  58.     keep rok suma;
  59. run;
  60.  
  61. *podaj 3 najdroższe auta dla każdej marki;
  62. proc sort data = sashelp.cars out = cars;
  63.     by make descending invoice;
  64. run;
  65.  
  66. data z7;
  67.     set cars;
  68.     by make;
  69.     if first.make then licznik = 0;
  70.     licznik + 1;
  71.     if licznik <= 3 then output;
  72. run;
  73.  
  74. proc sort data = sashelp.class out = class;
  75.     by descending height;
  76. run;
  77.  
  78. data zz1;
  79.     set class;
  80.     by sex;
  81.     *if first.sex then output;
  82. run;
  83.  
  84. data zz2;
  85.     set sashelp.class;
  86.     retain min min(height);
  87.     delta_height = height - min;
  88. run;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement