Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc sql;
- create z1 as select make,count (*) as cnt,count(distinct type) as type_cnt,sum(invoice)as suma from sashelp.cars() group by make;
- create table z2 as select make,count(*) as cnt,count(distinct type) as type_cnt,sum(invoice) as suma from sashelp.cars where origin='Europe' group by make having count(*)>5;
- create table z3 as select make,count(*) as cnt, sum(case when invoice >= 40000 then 1 else 0 end) as col1, sum(case when invoice < 40000 then 1 else 0) as col2,
- calculated cnt = calculated col1 + calculated col2 as col3,
- sum(type='Sedan') as sedan_cnt,
- sum(type='Suv') as suv_cnt,
- sum(type'Sports') as sports_cnt,
- from sashelp.cars
- group by 1;
- create table z4 as select make,count(*) as cnt,(count(*)/ (select count(*) fromsashelp.cars))*100 A C21
- FROM sashelp.cars
- group by make;
- create table ONE
- values (1,'a')
- values(2,'b')
- values(2,'c')l
- create table two(X num, Bchar1(1));
- insert into two
- values (1,'x')
- values(1,'y')
- values(3,'z');
- create table z5 as select t.*, two.B from one as t,two
- *"inner join";
- create table z6 as select t.6*,two.B from one as t,two where t.X=two.B from one as t inner join two on t.X=two.X;
- *left/right join;
- create table z8 as select t.*,two.B
- from one as t left join two on t.x=two.X;
- *full join;
- create table z8 as select coalesce(t.X,two.X) as X, t.X as one_x, two.X as two x, a,b from one as t full join two t.x=two.x;
- data pierwsza;
- do i=1 to 10 by 1;
- kolumna_a='A';
- kolumna_b=i*2;
- output;
- end;
- run;
- data druga;
- do i=1 to 10 by 1;
- kolumna_a='A';
- kolumna_b=i*2;
- if i=1 then kolumna_b=1;
- if i=10 then kolumna_b=10;
- output;
- end;
- run;
- *operatory;
- proc sql;
- create table z1 as select * from pierwsza union all /*suma wierszy, nie usuwa duplikatów*/
- select * from druga
- proc sql;
- create table z12 as select * from pierwsza intersect /*część pierwsza*/
- select * from druga
- proc sql;
- create table z122 as select * from pierwsza except select * from druga /*suma wierszy, nie usuwa duplikatów*/
- select * from druga
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement