2. sort data 根据postalcode和递减的income。 在每个postalcode中,挑出含有最高income的观测。要用到first.
. Χproc sort data = cert.input02 out = data02;
by postalcode descending income;
run;
data results.output02;
set data02;
by postalcode descending income;
if first.postalcode ;
run;. check 1point3acres for more.
3. Merge two datasets with common variable . One dataset contains variables Product and Qty, another contains variables Product and Price. 要求在输出的output dataset中新建一个variable名叫total, total = Qty * Price
在merge data1 data2; by XXX;之前,首先分别sort它们
4. 根据age输出三个数据,results.output04young results.output04mid results.output04notasyoung 并计算 mean sum
. ----
data results.output04Young results.output04Mid results.output04notasyoung; .. set cert.input04;
if age LE 40 then output results.output04Young;
else if age LE 60 then output results.output04Mid;
else if <这里加上了另一个条件> then output results.output04notasyoung;
run;
Data cert.input05;
Input name $ city $ 3-10 major $ 12-27 class $ test1 test2 test3 test4;
Datalines;
A Beijing math senior 5 4 3 4
B Beijing math senior 2 1 1 5
C Tianjin history senior 5 5 5 5
D Shanghai history and ball junior 4 4 4 4
E Hebei ball and reading junior 1 1 2 3
F Beijing run junior 2 2 1 2
G Beijing run and ball senior 5 4 5 1. .и
;
Run;. 1point 3acres
. Waral dи,
data results.output05 (drop = n);
set cert.input05;
n = find(major,'and','i');
if n ^= 0 then do;
second_major = substr(major,n+4);.--
major = substr(major,1,n-1);
end;
run;
proc freq data = results.output05;
tables major second_major;
run;
6. 还有个lab记不清了
-baidu 1point3acres
lab7 & 8 改错。读log根据提示改错,一般是data名字拼错误 young 变成younger,大小设定不精准 <= 和 < 之类的。。