Advertisement
Womee

Untitled

Jan 26th, 2020
2,706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.61 KB | None | 0 0
  1. proc sql;
  2.     describe table sashelp.cars;
  3.     select *
  4.     from sashelp.cars;
  5. quit;
  6.  
  7. proc sql;
  8.     select make, model, invoice
  9.     from sashelp.cars(drop = MPG_: )
  10.     /*where make = "Audi";*/
  11.     /*where lowcase(make) eq "audi"*/
  12.     /*where make = "Audi" or make = "BMW";*/
  13.     /*where make in ("Audi", "BMW");*/
  14.     where upcase(make) like "_A%";
  15.     /*% - wiele znaków, _ - jeden znak*/
  16. quit;
  17.  
  18. proc sql;
  19.     create table z2 as
  20.     select make, model, invoice
  21.     from sashelp.cars(where=(make eq "BMW"))
  22.     where horsepower >= 200;
  23. quit;
  24.  
  25. proc sql;
  26.     create table z3 as
  27.     select make, type
  28.     from sashelp.cars;
  29. quit;
  30.  
  31. *transformacje;
  32.  
  33. proc sql;
  34.     create table z4 as
  35.     select make length=200,
  36.            model,
  37.            type,
  38.            0,2*invoice as rabat
  39.             label = "Rabat w z1"
  40.             format = commax10.2
  41.     from sashelp.cars;
  42. quit;
  43.  
  44. *case when;
  45. proc sql;
  46.     create table z5 as
  47.     select make, model, invoice,
  48.     case when invoice lt 40000 then "tanie"
  49.          when invoice lt 60000 then "przecietne"
  50.          else "drogie"
  51.     end as kategoria
  52.     from sashelp.cars;
  53. quit;
  54. *calculated;
  55. proc sql;
  56.     create table z6 as
  57.     select make,
  58.            model,
  59.            4.5*invoice as invoice,
  60.            case when calculated invoice lt 40000 then "tanie"
  61.                 when invoice lt 60000 then "przecietne"
  62.                 else "drogie"
  63.            end as kategoria
  64.     from sashelp.cars;
  65. quit;
  66.  
  67. *top;
  68. proc sql outobs=10;
  69.     create table z7 as
  70.     select make, model, max(invoice) as naj
  71.     from sashelp.cars
  72.     group by make
  73.     having invoice = max(invoice)
  74.     oreder by naj;
  75. quit;
  76.  
  77. *monotonic;
  78. proc sql;
  79.     create table z8 as
  80.     select make, model, invoice
  81.     from sashelp.cars
  82.     where monotonic() <= 10;
  83. quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement