1.怎樣用sas將數據分類出只有特定年份的數據給個方向,你自己試看看datatest;formatdateyymmdd10.;f
給個方向, 你自己試看看
data test;
format date yymmdd10. ;
format time time8.;
date = '01jan2013'd;
do time = '15:45:00't to '16:15:00't by 60;
output;
end;
date = '02jan2013'd;
do time = '15:45:00't to '16:15:00't by 60;
if time ^='16:00:00't then output;
end;
run;
data want;
set test;
time_lag = lag(time);
if time = '16:00:00't then output;
else if time - '16:00:00't > 0 and time_lag - '16:00:00't
這樣做可以把數據集做成你要的截圖的形式。
data example;
input no number cost;
cards;
1 1 10
1 2 12
1 3 52
2 4 67
3 5 18
3 6 108
4 7 21
5 8 36
6 9 55
;
run;
proc means data=example sum;
by no;
var cost;
output out=result sum=total;
run;
data total(drop=_TYPE_ _FREQ_);
merge example result;
by no;
if no=lag(no) then total='';
run;
以 "5.0千克 "為例:
data exe;
a = '5.0千克';
run;
data exe2;set exe;
b = TRIM(a); /*除去尾部空格*/
d2 = length(b); /*計算字符串長度*/
c =substr(b,length(b)-3,4); /*一個中文占兩個字符長度,5.0千克長度為7,從 第4位向后取4個字符結果為:千克*/
run;
這個要非常注意,SAS對于中文支持不怎么好。你要注意半角和全角的括號,以及一些標點符號到底占用幾個字符長度,否則截取會出現亂碼。
標簽:交通新聞,
本文僅代表作者觀點,不代表陽光網立場。
上一篇:什么品牌沐浴露最好用
下一篇:返回列表