문제

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