SAS/python
·
#python
noaa=pd.read_csv('c:\python\a.csv')
#SAS
proc import datafile='c:\python\a.csv' out=noaa dbms=csv replace;
#python
noaa.head(5)
len(noaa)
#SAS
proc print data=noaa(obs=5);#因为在SAS里观测的数目直接输出在日志里
#python
noaa_index=pd.Datetime_index(noaa['Date'])
#SAS
n/a#SAS中不可以这么操作
#python
noaa.drop(['ID'],axis=1,inplace=True)
#SAS
set noaa(drop=ID);
#python
noaa['Year']=noaa_index.strftime("%Y")
#SAS
Year=year(date);
Mo=put(month(date),$2.);
Day=put(day(date),$2.);
#python
noaa=noaa.loc[noaa['MoDay']!="02-29"]
#SAS
if MoDay ne '02-29'
#python
noaa=['data_value']=noaa['Data_Value']/10
#SAS
data_vale=data_value/10;
#python
noaa_2015=noaa.loc[noaa['Year']=="2015"]
#SAS
if Year=2015 then output noaa_2015;
#python
noaa['Year']="2015"
#SAS
Year=2015;
output noaa;
#python
max_10=noaa[noaa['element']=="tmax"].groupby(['moday'])["data_value"].max()
max_10=np.array(list(max_10))
#SAS
proc sql;
create table max_10 as
select moday,max(data_value) as max_10;
from noaa
where element='tmax'
group by monday
#python
max_2015=noaa_2015[noaa_2015['element']=='tmax'].groupby(['moday'])['data_value'].max()
#SAS
proc sql;
create table max_2015 as
select moday,max(data_value) as max_2015
from noaa_2015
where element='tmax'
group by moday;
#python
max_break_points=(max_2015>max_10).as_matraix()
#SAS
proc sql;
create table max_break_points as
select Max_2015.moday,max_2015
from max_2015 full join max_10
on max_2015.moday=max_10.moday
where max_2015.max_2015>max_10.max_10;
更多推荐



所有评论(0)