使用循环条件在SAS中相乘列

使用循环条件在SAS中相乘列,sas,sas-macro,sas-studio,Sas,Sas Macro,Sas Studio,在本表中,Trans_Date一栏持续至2016年7月31日 如何将循环下的值列乘以汇率列(以NZD、CAD、GBP表示的澳元货币兑换,如特定日期的货币兑换)以仅以澳元显示每个订单号的值 “货币”列应仅以澳元为单位 您是否要求将每种货币每天的澳元兑换率乘以相应的条目 为此,您可以尝试以下方法: 首先,创建一个新表: proc sql noprint; create table rates as select * from table where Currency = 'AUD' order by

在本表中,Trans_Date一栏持续至2016年7月31日

如何将循环下的值列乘以汇率列(以NZD、CAD、GBP表示的澳元货币兑换,如特定日期的货币兑换)以仅以澳元显示每个订单号的值


“货币”列应仅以澳元为单位

您是否要求将每种货币每天的澳元兑换率乘以相应的条目

为此,您可以尝试以下方法:

首先,创建一个新表:

proc sql noprint;
create table rates as
select * from table
where Currency = 'AUD'
order by Trans_date;
quit;

data rates;
set rates;
by Trans_date;
output;
if last.Trans_date then do;
  currency_conv = 'AUD';
  rate = 1.;
  output;
end;
run;
现在连接表:

proc sql noprint;
create table as newTable
select a.*,a.value*b.rate as newValue
from table as a
left join (select * from rates) as b
on a.Trans_date = b.Trans_date
and a.currency = b.currency_conv;
quit;

数据的图片没有帮助。请在问题文本中输入示例数据、所需输出以及您尝试过的代码。你的问题真的是“如何在SAS中乘以两个变量?”答案是var1*var2。但我会寻找一些基本的在线教程和文档。