SAS retain 语句data sample;input ID $ type income;cards;1 1 2001 2 3001 3 1002 1 2002 3 1002 4 100;run;data new_sample;set sample;by id;retain new_income;if first.id then new_income=0;new_income+income;if last.id then output;drop income type;run;da

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 10:13:54
SASretain语句datasample;inputID$typeincome;cards;112001230013100212002310024100;run;datanew_sample;set

SAS retain 语句data sample;input ID $ type income;cards;1 1 2001 2 3001 3 1002 1 2002 3 1002 4 100;run;data new_sample;set sample;by id;retain new_income;if first.id then new_income=0;new_income+income;if last.id then output;drop income type;run;da
SAS retain 语句
data sample;
input ID $ type income;
cards;
1 1 200
1 2 300
1 3 100
2 1 200
2 3 100
2 4 100
;
run;
data new_sample;
set sample;
by id;
retain new_income;
if first.id then new_income=0;
new_income+income;
if last.id then output;
drop income type;
run;
data new_sample2;
set sample;
by id;
if first.id then new_income=0;
new_income+income;
if last.id then output;
drop income type;
run;
为什么这两个程序结果一样?体现不出来retain的作用啊?

SAS retain 语句data sample;input ID $ type income;cards;1 1 2001 2 3001 3 1002 1 2002 3 1002 4 100;run;data new_sample;set sample;by id;retain new_income;if first.id then new_income=0;new_income+income;if last.id then output;drop income type;run;da
累加语句new_income+income;相当于下面的程序段:
retain new_income 0;
new_income=sum(new_income,income);
所以说,上面的两个程序都使用了retain的功能,结果当然一样!
想体现出retain的作用,可以试试把累加语句new_income+income;改为
new_income=sum(new_income,income);

SAS retain 语句data sample;input ID $ type income;cards;1 1 2001 2 3001 3 1002 1 2002 3 1002 4 100;run;data new_sample;set sample;by id;retain new_income;if first.id then new_income=0;new_income+income;if last.id then output;drop income type;run;da 在SAS中keep语句放在data后和放在set后有什么区别? retain sas程序中data abc;是? 有关SAS的程序说明data work.profit;infile sales;input Year 1-4 Expenses 6-10 Revenue 12-16;run;proc means data=work.profit;run;proc print data=work.profit;run;proc sort data=work.profit;by year;run;这个程序每个语句的意思~ 谁能帮我做几个SAS简单的题目.谁能帮我做几个SAS简单的题目,就是解释语句1.data a;merge fdata.hqck101 (keep=date number rename=(number=num101))fdata.hqck199 (keep=date number rename=(number=num199));by date;run;2.data year199 SAS的proc model语句应该怎么用?即proc model data=a;然后接下来常用的语句怎么写?你说的我懂,我就是想问proc model这个语句,是个解方程用的语句,教材上都找不到... SAS sas SAS语句求解~~请问一下语句什么意思?其中,egv数据集已经存在.尤其是其中:If n=1 then set egv;一句.得到的结果很是奇怪,不是选择,而是向下全部读取.若需要全部语句请吱声~~多谢了.Data egv; Set pri 请教统计软件sas操作问题!proc reg data= example6_1;model y=x;output out=out residual=residual;run;proc arima data=out;identify var=residual stationarity=(adf);run;请问这两段语句怎样解释,各有什么用途? sas中alpha是什么意思sas语句proc ttest h=100 alpha=0.1; 求残差自回归 预测 sas操作语句.最好具体的. no=input(a,?best.); 什么意思? (SAS)语句 retain是什么意思 请解释此语句含义及其语法(SA *) &servaddr DATA Data