Advertisement
Womee

Untitled

Jan 26th, 2020
3,319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.63 KB | None | 0 0
  1. data tabela_a;
  2.     do i=1 to 1000;
  3.     kolumna_a=1;
  4.     output;
  5.     end;
  6. run;
  7.  
  8. data tabela_b;
  9.     do i=1 to 1500 by 10;
  10.     kolumna_b='AAA';
  11.     output;
  12.     end;
  13. run;
  14.  
  15. *³ıczenie zbiorów;
  16. data z1;
  17.     set tabela_a tabela_b indsname=zrodlo;
  18.     zbior=zrodlo;
  19. run;
  20.  
  21. data z1;
  22.     set tabela_a(in=in1) tabela_b(in=in2);
  23.     z1=in1;
  24.     z2=in2;
  25. run;
  26.  
  27. *interleaving;
  28. proc sort data=tabela_a out=tabela_a;
  29.     by i;
  30. run;
  31. proc sort data=tabela_b out=tabela_b;
  32.     by i;
  33. run;
  34. data z2;
  35.     set tabela_a tabela_b;
  36.     by i;
  37. run;
  38.  
  39. *merge;
  40. *dane musza byc posortowane;
  41. proc sort data=tabela_a out=tabela_a;
  42.     by i;
  43. run;
  44. proc sort data=tabela_b out=tabela_b;
  45.     by i;
  46. run;
  47.  
  48. data z3;
  49.     merge tabela_a tabela_b;
  50. run;
  51.  
  52. *merge + klucz;
  53. *dane musza byc posortowane;
  54. *identyczne nazwy kolumn do laczenia;
  55. data z4;
  56.     merge tabela_a(in=in1) tabela_b(in=in2);
  57.     by i; *klucz;
  58.     z1=in1;
  59.     z2=in2;
  60. run;
  61.  
  62. *inner join;
  63. data z4;
  64.     merge tabela_a(in=in1) tabela_b(in=in2);
  65.     by i; *klucz;
  66.     if in1=1 and in2=1;
  67. run;
  68.  
  69. *left join;
  70. data z4;
  71.     merge tabela_a(in=in1) tabela_b(in=in2);
  72.     by i; *klucz;
  73.     if in1=1;
  74. run;
  75.  
  76. *klucze, ktore sie nie lacza;
  77. data z6;
  78.     merge tabela_a(in=in1) tabela_b(in=in2);
  79.     by i; *klucz;
  80.     if in1=0 or in2=0;
  81. run;
  82.  
  83. *klucze wystepujace w tabela_a, ale nie wystapily w tabela_b;
  84. data z7;
  85.     merge tabela_a(in=in1) tabela_b(in=in2);
  86.     by i; *klucz;
  87.     if in1=1 and in2=0;
  88. run;
  89.  
  90. data wynik;
  91.     set tabela_a;
  92. run;
  93.  
  94. proc append base=wynik data=tabela_b force;
  95. run;
  96.  
  97. libname X 'C:\Users\student\Desktop\zbiory_laczenie_sas';
  98. data zz1;
  99.     set X.popularnames_2011 X.popularnames_2012 X.popularnames_2013 X.popularnames_2014 indsname=in;
  100.     rok=in;
  101. run;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement