wenchongange 发表于 2010-1-18 14:44 
现在有多张表格,每张记录每个地区的每个城市人口数,最后一行是人口总数。请问怎样编写语言要把这“每个”最后一行抽出来,组成新表呢,而且新表里要有地区名和人口总数?谢谢,急求答案
Use the options ( nobs=last point=last) on set statement. The advantage is read 3 rows instead of 15 rows in the following example. It is much efficient.
28 data t1 t2 t3;
29 do i=1 to 3;
30 output t1;
31 end;
32 do i=1 to 5;
33 output t2;
34 end;
35 do i=1 to 7;
36 output t3;
37 end;
38 run;
NOTE: The data set WORK.T1 has 3 observations and 1 variables.
NOTE: The data set WORK.T2 has 5 observations and 1 variables.
NOTE: The data set WORK.T3 has 7 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
39
40 data lastrows;
41 set t1 nobs=last point=last;
42 output;
43 set t2 nobs=last point=last;
44 output;
45 set t3 nobs=last point=last;
46 output;
47 stop;
48
49 run;
NOTE: The data set WORK.LASTROWS has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds