Вопрос

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

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;

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.

Another approach:

data tmp;
 set your_table;
 if _n_=1 then do;
  call symputn('n',a+b);
 end;
run;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top