SAS SQL
- 语法
- SQL CREATE
- SQL SELECT
- SQL SELECT with WHERE Clause
- SQL UPDATE
- SQL DELETE
语法
proc sql;select columnsfrom tablewhere columnsgroup by columns
;
quit;
SQL查询在proc sql语句之后,加上quit语句,用于结束SQL查询
SQL CREATE
data example;input id $ name $ studynum;datalines;1 Maria 20241680012 Michelle 20241680023 Lucy 20241680034 Gary 2024168004;
run;proc sql;create table temp asselect * from example
;
quit;
SQL SELECT
proc sql;select name,height,weightfrom sashelp.class
;
quit;
SQL SELECT with WHERE Clause
proc sql;select name,height,weightfrom sashelp.classwhere height > 60
;
quit;
SQL UPDATE
proc sql;create table class asselect name as student,sex as gender,age as year,height as stuheight,weight as stuweight,weight/((height/100)*(height/100)) as bmifrom sashelp.class;
quit;
proc sql;update classset stuheight=stuheight/100;
quit;
SQL DELETE
proc sql;delete from classwhere weight<60;
quit;