我曾用ODS语句将统计分析输出新的数据集,但仍不能将其中某个结果输出为新的变量,本人使用SAS很不熟,较愚笨。
为实现该功能,编了个简单程序如下:
-------------------------------------------------------------------------
data a;
do unit=1 to 20; /* 待分组的样本数 */
output;
end;
run;
data M1;
set a;
infile 'c:\testyy.txt'; /* 包含编号、体重的纯文本数据 */
input bh tz; /*编号bh,体重tz */
这个语句运行了,不行。 <!-- s:( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":(" title="Sad" /><!-- s:( -->
46 select variance into: variable from Measures;
[color=#FF0000:ngh1ao3q]ERROR: The following columns were not found in the contributing tables: variance.[/color:ngh1ao3q]作者: shiyiming 时间: 2013-1-30 22:30 标题: Re: SAS如何将统计分析的某个结果作为新的变量 [quote="qwtrain":drshkws2]具体的用法你其实可以查sas help,我最近也是在学SAS,将我的理解讲一下:
还有一种将一个变量的值赋给另外一个新变量可以用语句
data _null_;
set Measures;
call symput('variable',variance);
run;
这个也是将变量variance的值赋值给一个新的变量宏variable[/quote:drshkws2]
[color=#FF0000:drshkws2]NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
74:24[/color:drshkws2]作者: shiyiming 时间: 2013-1-30 22:44 标题: Re: SAS如何将统计分析的某个结果作为新的变量 [quote="MerlinZHOU":1vxmjluy]Univariate过程有输出结果到数据集的选项,你可以参考sad base中的用法,把结果输出到数据集后,你就可以象处理一般数据集中的观测一样,处理你上一步的分析结果[/quote:1vxmjluy]
proc sql noprint;
select count(*) as n format=3. into :n
from Sashelp.fish
;
select LocValue into :Mean
from Measures
where LocMeasure='Mean'
;
select LocValue format=6.4 into :Median
from Measures
where LocMeasure='Median'
;
select LocValue format=5.3 into :Mode
from Measures
where LocMeasure='Mode'
;
select VarValue format=6.4 into :Std
from Measures
where VarMeasure='Std Deviation'
;
quit;
%put NOTE: Fish Sample Size=&n, Mean=&Mean, the Midian=&median, and the Mode=&Mode, STD=&std..;
ods results;
ods listing;