SAS再学习笔记: from johnthu.spaces.live.com
分号结尾,free format(一行可以多个),大小写不敏感,Data case sensitive /*注释或者 * ;注释,推荐后者
只有两种数据类型:numeric,character
分为DATA steps PROC steps,常用RUN分割.Datastep will read line by line (observation) automatically,读入OUTPUT数据集. 也可用retain/output控制上次读入/输出
读入
*Read internal data into SAS data set uspresidents;
DATA uspresidents;
INPUT President $ Party $ Number;
DATALINES;
Adams F 2
Lincoln R 16
Grant R 18
Kennedy D 35
读文件
INFILE 'c:\a.txt' *precede INPUT is a must,且用单引号,默认记录长13,用LRECL=改
INPUT uspresidentname $ party $ age *字符变量用$结尾
list input(自由格式input,空格分隔,句号表示缺,可以折行
??result window分段看输出??
DATA distance; *将建立work.distance数据集
Miles= 26.22
KiloMeter=Miles*1.61
PROC PRINT DATA=distance;
RUN
PROC 过程名 [DATA=数据集] [option];
专用语句描述;
[VAR 变量序列;]
[WHERE condition;]
[BY var seq;]
Run;
例如PROC print;
Var x;
Run;
title "my1st" //因为这个
data temp;
input x y@@;
cards;
34 45 67 1 23 6
;
proc print;
run;
quit;
PROC gplot data=temp;
plot y*x;
run;
条件:if score1 ge 95 or score2 ge 95 or score3 ge 95 then
put ID= Score1= Score2= Score3=; *输出
Every DATA step has an implied OUTPUT statement at the end which tells SAS to write the current observation to the output data set before returning to the beginning of the DATA step to process the next observation.
KEEP = variable-list tells SAS which variables to keep.
DROP
RENAME = (oldvar = newvar) tells SAS to rename certain variables.
FIRSTOBS = n tells SAS to start reading at observation n.
OBS = n tells SAS to stop reading at observation n.
IN = new-var-name creates a temporary variable for tracking whether
that data set contributed to the current observation.
totalquantity+quantity; * in a loop or input adding quantity up to total;
array monthsales{12}
do i =1 to 12
monthsales{i}=sales;
end;
PROC format:proc format; * can use Label as notes
value $gender 'M' = 'Male'
'F' = 'Female'
PROC ANOVA 方差分析
_n_ 系统变量,表明是第几条读入变量
Proc import (import data files csv,access
X2检验:频率是否有区别
ROW=1,2, COLUMN=1,2 NUMBER=44(cured),55(cured),4(failed),5(failed)
PROC FREQ
TABLE ROWVariablName*COLUMNVN CHISQ
WEIGHT NUMBER
UNIVARIATE,MEANS,NPAR1WAY三种非参数校验(理论基础不足)
SAS学习笔记:开篇
准备SAS程序员认证,从基础开学。材料就是:
SAS OnlineTutor®: Basic and Intermediate SAS®
Introduction to SAS Programming
Basic Concepts
Using the Programming Workspace
Referencing Files and Setting Options
Editing and Debugging SAS Programs
Creating List Reports
Creating SAS Data Sets from Raw Data
Understanding DATA Step Processing
Producing Reports
Creating and Applying User-Defined Formats
Creating Enhanced List and Summary Reports
Producing Descriptive Statistics
Producing HTML Output
Creating Tabular Reports
Enhancing HTML Tabular Reports
Producing Graphical Reports
These lessons are not suitable for use with SAS Enterprise Guide.
Creating Plots
Creating Bar and Pie Charts
Enhancing and Exporting Charts and Plots
Creating Drill-Down Graphs in HTML
Creating and Modifying SAS Data Sets
Creating and Managing Variables
Reading SAS Data Sets
Combining SAS Data Sets
Performing Queries Using PROC SQL
Transforming Data with SAS Functions
Accessing DBMS Data
This lesson is not suitable for use with SAS Enterprise Guide.
Generating Data with DO Loops
Processing Variables with Arrays
Improving Program Efficiency with Macro Variables
Reading Various Types of Raw Data
Reading Raw Data in Fixed Fields
Reading Free-Format Data
Reading Date and Time Values
Creating a Single Observation from Multiple Records
Creating Multiple Observations from a Single Record
Reading Hierarchical Files
Reading Variable-Length Records
只有两种数据类型:numeric,character
分为DATA steps PROC steps,常用RUN分割.Datastep will read line by line (observation) automatically,读入OUTPUT数据集. 也可用retain/output控制上次读入/输出
读入
*Read internal data into SAS data set uspresidents;
DATA uspresidents;
INPUT President $ Party $ Number;
DATALINES;
Adams F 2
Lincoln R 16
Grant R 18
Kennedy D 35
读文件
INFILE 'c:\a.txt' *precede INPUT is a must,且用单引号,默认记录长13,用LRECL=改
INPUT uspresidentname $ party $ age *字符变量用$结尾
list input(自由格式input,空格分隔,句号表示缺,可以折行
??result window分段看输出??
DATA distance; *将建立work.distance数据集
Miles= 26.22
KiloMeter=Miles*1.61
PROC PRINT DATA=distance;
RUN
PROC 过程名 [DATA=数据集] [option];
专用语句描述;
[VAR 变量序列;]
[WHERE condition;]
[BY var seq;]
Run;
例如PROC print;
Var x;
Run;
title "my1st" //因为这个
data temp;
input x y@@;
cards;
34 45 67 1 23 6
;
proc print;
run;
quit;
PROC gplot data=temp;
plot y*x;
run;
条件:if score1 ge 95 or score2 ge 95 or score3 ge 95 then
put ID= Score1= Score2= Score3=; *输出
Every DATA step has an implied OUTPUT statement at the end which tells SAS to write the current observation to the output data set before returning to the beginning of the DATA step to process the next observation.
KEEP = variable-list tells SAS which variables to keep.
DROP
RENAME = (oldvar = newvar) tells SAS to rename certain variables.
FIRSTOBS = n tells SAS to start reading at observation n.
OBS = n tells SAS to stop reading at observation n.
IN = new-var-name creates a temporary variable for tracking whether
that data set contributed to the current observation.
totalquantity+quantity; * in a loop or input adding quantity up to total;
array monthsales{12}
do i =1 to 12
monthsales{i}=sales;
end;
PROC format:proc format; * can use Label as notes
value $gender 'M' = 'Male'
'F' = 'Female'
PROC ANOVA 方差分析
_n_ 系统变量,表明是第几条读入变量
Proc import (import data files csv,access
X2检验:频率是否有区别
ROW=1,2, COLUMN=1,2 NUMBER=44(cured),55(cured),4(failed),5(failed)
PROC FREQ
TABLE ROWVariablName*COLUMNVN CHISQ
WEIGHT NUMBER
UNIVARIATE,MEANS,NPAR1WAY三种非参数校验(理论基础不足)
SAS学习笔记:开篇
准备SAS程序员认证,从基础开学。材料就是:
SAS OnlineTutor®: Basic and Intermediate SAS®
Introduction to SAS Programming
Basic Concepts
Using the Programming Workspace
Referencing Files and Setting Options
Editing and Debugging SAS Programs
Creating List Reports
Creating SAS Data Sets from Raw Data
Understanding DATA Step Processing
Producing Reports
Creating and Applying User-Defined Formats
Creating Enhanced List and Summary Reports
Producing Descriptive Statistics
Producing HTML Output
Creating Tabular Reports
Enhancing HTML Tabular Reports
Producing Graphical Reports
These lessons are not suitable for use with SAS Enterprise Guide.
Creating Plots
Creating Bar and Pie Charts
Enhancing and Exporting Charts and Plots
Creating Drill-Down Graphs in HTML
Creating and Modifying SAS Data Sets
Creating and Managing Variables
Reading SAS Data Sets
Combining SAS Data Sets
Performing Queries Using PROC SQL
Transforming Data with SAS Functions
Accessing DBMS Data
This lesson is not suitable for use with SAS Enterprise Guide.
Generating Data with DO Loops
Processing Variables with Arrays
Improving Program Efficiency with Macro Variables
Reading Various Types of Raw Data
Reading Raw Data in Fixed Fields
Reading Free-Format Data
Reading Date and Time Values
Creating a Single Observation from Multiple Records
Creating Multiple Observations from a Single Record
Reading Hierarchical Files
Reading Variable-Length Records
0 Comments:
Post a Comment
<< Home