请选择 进入手机版 | 继续访问电脑版
楼主: lnlhckao123
12882 4

[问答] 100论坛币求sas中output及out的用法并举例 [推广有奖]

  • 0关注
  • 3粉丝

副教授

61%

还不是VIP/贵宾

-

威望
0
论坛币
14832 个
通用积分
9.1001
学术水平
7 点
热心指数
4 点
信用等级
4 点
经验
12566 点
帖子
754
精华
0
在线时间
399 小时
注册时间
2010-8-21
最后登录
2024-2-8

lnlhckao123 发表于 2014-12-22 00:56:56 |显示全部楼层 |坛友微信交流群
100论坛币
求高手解答sas中output及out的用法并举例,谢谢!

最佳答案

fortr_cc 查看完整内容

不好意思,没用过SAS, 不过所附文件因该有你要的答案(及例子)。 一常用例子是 Saving Summary Statistics in an OUT= Output Data Set This example illustrates how to save summary statistics in an output data set. The following statements create a data set named Belts, which contains the breaking strengths (Strength) and widths (Width) of a sample of 50 automotive seat belts: data Belts; labe ...
关键词:output 100论坛币 outpu 0论坛币 Out
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!
fortr_cc 发表于 2014-12-22 00:56:57 |显示全部楼层 |坛友微信交流群
不好意思,没用过SAS, 不过所附文件因该有你要的答案(及例子)。

一常用例子是 Saving Summary Statistics in an OUT= Output Data Set

This example illustrates how to save summary statistics in an output data set. The following statements create a data set named Belts, which contains the breaking strengths (Strength) and widths (Width) of a sample of 50 automotive seat belts:
data Belts;
   label Strength = 'Breaking Strength (lb/in)'
         Width    = 'Width in Inches';
   input Strength Width @@;
   datalines;
1243.51  3.036  1221.95  2.995  1131.67  2.983  1129.70  3.019
1198.08  3.106  1273.31  2.947  1250.24  3.018  1225.47  2.980
1126.78  2.965  1174.62  3.033  1250.79  2.941  1216.75  3.037
1285.30  2.893  1214.14  3.035  1270.24  2.957  1249.55  2.958
1166.02  3.067  1278.85  3.037  1280.74  2.984  1201.96  3.002
1101.73  2.961  1165.79  3.075  1186.19  3.058  1124.46  2.929
1213.62  2.984  1213.93  3.029  1289.59  2.956  1208.27  3.029
1247.48  3.027  1284.34  3.073  1209.09  3.004  1146.78  3.061
1224.03  2.915  1200.43  2.974  1183.42  3.033  1195.66  2.995
1258.31  2.958  1136.05  3.022  1177.44  3.090  1246.13  3.022
1183.67  3.045  1206.50  3.024  1195.69  3.005  1223.49  2.971
1147.47  2.944  1171.76  3.005  1207.28  3.065  1131.33  2.984
1215.92  3.003  1202.17  3.058
;
run;

The following statements produce two output data sets containing summary statistics:

proc univariate data=Belts noprint;
   var Strength Width;
   output out=Means         mean=StrengthMean WidthMean;
   output out=StrengthStats mean=StrengthMean std=StrengthSD
                            min=StrengthMin   max=StrengthMax;
run;


When you specify an OUTPUT statement, you must also specify a VAR statement. You can use multiple OUTPUT statements with a single procedure statement. Each OUTPUT statement creates a new data set with the name specified by the OUT= option. In this example, two data sets, Means and StrengthStats, are created.

sas-output.pdf

81.78 KB

已有 2 人评分经验 论坛币 收起 理由
李会超 + 60 精彩帖子
admin_kefu + 50 精彩帖子

总评分: 经验 + 60  论坛币 + 50   查看全部评分

使用道具

lchw001 发表于 2014-12-22 02:44:38 |显示全部楼层 |坛友微信交流群
在运行之前加上ods trace on;SAS的log日志里会显示出各个output的数据名字。然后用ods output 数据名=新命名。之后就可以在work library里找到那个导出的数据了。

使用道具

fortr_cc 发表于 2014-12-22 03:16:49 |显示全部楼层 |坛友微信交流群
以下LINK 有其他例子:

http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_univariate_sect016.htm

OUTPUT Statement
OUTPUT <OUT=SAS-data-set < keyword1=names ...keywordk=names > < percentile-options >> ;
The OUTPUT statement saves statistics and BY variables in an output data set. When you use a BY statement, each observation in the OUT= data set corresponds to one of the BY groups. Otherwise, the OUT= data set contains only one observation.
You can use any number of OUTPUT statements in the UNIVARIATE procedure. Each OUTPUT statement creates a new data set containing the statistics specified in that statement. You must use the VAR statement with the OUTPUT statement. The OUTPUT statement must contain a specification of the form keyword=names or the PCTLPTS= and PCTLPRE= specifications. See Example 4.7 and Example 4.8.
OUT=SAS-data-set
identifies the output data set. If SAS-data-set does not exist, PROC UNIVARIATE creates it. If you omit OUT=, the data set is named DATAn, where n is the smallest integer that makes the name unique.
keyword=names
specifies the statistics to include in the output data set and gives names to the new variables that contain the statistics. Specify a keyword for each desired statistic, followed by an equal sign, followed by the names of the variables to contain the statistic. In the output data set, the first variable listed after a keyword in the OUTPUT statement contains the statistic for the first variable listed in the VAR statement, the second variable contains the statistic for the second variable in the VAR statement, and so on. If the list of names following the equal sign is shorter than the list of variables in the VAR statement, the procedure uses the names in the order in which the variables are listed in the VAR statement. The available keywords are listed in the following tables:

。。。

使用道具

shajialin 发表于 2021-7-23 09:43:40 |显示全部楼层 |坛友微信交流群
感谢,虽然目前还是云里雾里的,太难了

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-29 13:02