SAS let 语句:引用单元格值? [英] SAS let statement: refer to a cell value?

查看:33
本文介绍了SAS let 语句:引用单元格值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SAS 中,是否可以将 %let 语句引用到位于数据库中的值?

In SAS, is it possible to refer a %let statement to a value located in a database?

例如,%let n=50 中 my n 的值取决于在我的一个数据库中计算的某个值,例如,第一行加第一列.而且由于该值在我的循环中被修改了 100 次,我不想手动输入该值.

For instance, the value of my n in %let n=50 depends on some value calculated in one of my databases, e.g., first row plus first column. And since that value gets modified 100 times in my loop I don't want to manually enter that value.

推荐答案

有几种方法可以做到这一点.这里有两个:

There's several ways to do this. Here's two:

proc sql;
 select a+b into :n
 from your_table
 where some_condition;
quit;

这会使用变量 ab 的总和填充宏变量 &n.您指定的条件应仅适用于表格的一行.

This populations a macro variable, &n, with the sum of the variables a and b. The condition you specify should be true only for one row of your table.

另一种方法:

data tmp;
 set your_table;
 if _n_=1 then do;
  call symputn('n',a+b);
 end;
run;

这篇关于SAS let 语句:引用单元格值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆