g*******y 发帖数: 380 | 1 下面的程序有什么问题?
proc sql;
create table a1 as select r_year, distinct code, local_nm
from climate
;
quit;
我想把'code'和'local_nm'是unique的列出来,同时显示对应的年份.
下面的程序是work的:
proc sql;
create table a1 as select distinct code, local_nm
from climate
;
quit;
但是我加入r_year,就出现一下提示:
214 create table a1 as select r_year, distinct code, local_nm
----
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, * | C******t 发帖数: 72 | 2 Try to move the distinct next to select:
proc sql;
create table a1 as select distinct r_year, code, local_nm
from climate
; | g*******y 发帖数: 380 | 3 谢谢,但是我只需要distinct code and local_nm, 我需要r_year只是起个定位作用,并
不需要 distinct r_year.
【在 C******t 的大作中提到】 : Try to move the distinct next to select: : proc sql; : create table a1 as select distinct r_year, code, local_nm : from climate : ;
| g*******y 发帖数: 380 | | f********t 发帖数: 117 | 5 it doesnt look like sas has distinct on ()
so I guess you can try to create
proc sql;
create temp table a1 as select distinct code, local_nm
from climate;
create table a2 as select a1.code, a1.local_nm, c.r_year from a1, climate c
where a1.code = c.code, a1.local_nm = c.local_nm;
quit;
I dont have sas to test, so you can try it. | p********a 发帖数: 5352 | |
|