[英]SAS Function Search
my data set includes billed amounts & refunds. 我的数据集包括账单金额和退款。 I'd like to match billed amounts and refunds together when relevant. 我想在相关时将帐单金额和退款进行匹配。 I have a unique identifier which allows me to see which rows should be added. 我有一个唯一的标识符,使我可以看到应该添加哪些行。 I've done this before easily enough using R Software but my data set is on SAS. 我已经使用R Software轻松完成了此操作,但是我的数据集位于SAS上。
Can anyone suggest a function in the Query Builder that will allow me to do this & perhaps illustrate how it is best used? 谁能在查询生成器中建议一个函数,该函数将允许我执行此操作并可能说明如何最好地使用它?
Many different possible ways. 许多不同的可能方式。 eg Proc SQL
, Proc Means
, Proc Summary
, Data Step
using double DOW. 例如,使用双DOW的Proc SQL
, Proc Means
, Proc Summary
, Data Step
。 Very easy would be group by
in Proc SQL
在Proc SQL
非常容易进行group by
proc sql;
create table data_want as
select a.*, sum(a.total) as new_total
from data_have a
group by a.UniqueID
;
quit;
Regarding the query builder (which will just produce proc sql
code): 关于查询生成器(只会生成proc sql
代码):
Summary
behind every selected variable. 为查询选择变量时,每个选定变量后面都有一列“ Summary
。 Set this to SUM for the total
Variable. 将其设置为SUM以获取total
变量。 proc sort input_data; by 'Unique Identifier' /*In_date*/;
run;
data result;
set input_data;
by 'Unique Identifier';
retain res_total 0;
if first.'Unique Identifier' then res_total = total;
res_total + total;
if last.'Unique Identifier' then output;
run;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.