一、首先拿sas的帮助文件举例
为啥要用sas来讲,使用的人又不多?
因为帮助文件的参数,格式表示都差不多的。而且,我重点讲符号是啥意思,是从语法规则的角度,不需要专业背景。后面我会多举其他帮助文档的例子。
(另外是我在现在在用它,我确实要解决这个问题!)
小编到一直看不懂˂˃符号,括号是什么意思
(sas不区分大小写,我就不写大写了)
1.UNIVARIATE 过程
PROC UNIVARIATE < options >
*它下面有很多参数,随便拿一条出来;
CIBASIC <(<TYPE=keyword> <ALPHA=α)>
requests confidence limits for the mean, standard deviation, and variance based on the assumption that the data are normally distributed. If you use the CIBASIC option, you must use the default value of VARDEF=, which is DF.
TYPE=keyword
specifies the type of confidence limit, where keyword is LOWER, UPPER, or TWOSIDED. The default value is TWOSIDED.
ALPHA=α
specifies the level of significance α for 100(1-α)% confidence intervals. The value α must be between 0 and 1; the default value is 0.05, which results in 95% confidence intervals. The default value is the value of ALPHA= given in the PROC statement.
经过试验,算是搞懂了这几种括号啥的么意思了(以前根本不想静下心来看帮助,有可以运行的代码就试一试,没有就直接百度中文帮助,经常就是找不到的,殊不知最好的教程其实是帮助文档)
- 1.尖括号˂˃内的内容,表示可有可无 ,尖括号本身不要输入
*正确写法;
PROC UNIVARIATE CIBASIC;
*错误写法;
PROC UNIVARIATE ˂CIBASIC˃;
- 2.圆括号要照写
*正确写法;
PROC UNIVARIATE CIBASIC(type=lower);
*正确写法;
PROC UNIVARIATE CIBASIC(type=lower alpha=0.02);
*错误写法;
PROC UNIVARIATE CIBASIC type=lower alpha=0.02;
2.更常用的means过程
PROC MEANS <option(s)> <statistic-keyword(s)>;
BY <DESCENDING> variable-1 <... <DESCENDING> variable-n><NOTSORTED>;
CLASS variable(s) </ option(s)>;
FREQ variable;
ID variable(s);
OUTPUT <OUT=SAS-data-set> <output-statistic-specification(s)>
<id-group-specification(s)> <maximum-id-specification(s)>
<minimum-id-specification(s)> </ option(s)> ;
TYPES request(s);
VAR variable(s) < / WEIGHT=weight-variable>;
WAYS list;
WEIGHT variable;
什么玩儿意?!好难受!
- by,class, FREQ,ID,OUTPUT在本页有介绍作用。
- 1.<statistic-keyword(s)> 是什么?
将“statistic-keyword”在sas帮助里搜一下。
索引结果.png
搜索结果.png
结果好多呀!难受。
索引是按主题来的,排在前面的基本就是它的专题。排在后面的是它出现的地方(配角,出来一下)搜索就排序很乱。
可以看出
<statistic-keyword(s)>可能是max,min,mean,std,sum等
感觉means这条帮助没写好;
data=啥,是必须要的;options,没有解释且搜不到。估计是指下面的东西吧:
CLASS,BY,FREQ,ID,OUTPUT,VAR,WAYS,WEIGHT。
其他的都可以省略(尖括号嘛)
*最简单的实例;
proc means data=sashelp.air cv;
run;
*VAR variable(s) < / WEIGHT=weight-variable>;
* VAR variable(s) 说明 var后直接跟空格+变量名;
*例子1;
proc means data=sashelp.air cv;
var air;
run;
*< /WEIGHT=weight-variable>说明权重变量可有可无,且weight前要有/;
*例子2;
proc means data=sashelp.air cv;
var air /WEIGHT= air;
run;
多写一点给你卡看
*BY <DESCENDING> variable-1 <... <DESCENDING> variable-n><NOTSORTED>;
*说明by可以按n个变量分组,˂DESCENDING˃可选升序还是降序,<NOTSORTED>可设置为不排序;
proc means data= sashelp.shoes max;
by DESCENDING product DESCENDING region NOTSORTED ;
run;
精简版
proc means data= sashelp.shoes ;
by product ;
run;
看不懂的参数?
下面两个应该是与id相关的
<id-group-specification(s)> <maximum-id-specification(s)>
<minimum-id-specification(s)> </ option(s)> ;
网友评论