s*******d 发帖数: 132 | 1 How to assign a bunch of numbers in a %do loop in a macro?
%do i=1, 3, 6, 7;
....
%end;
It doesn't work in SAS
Any sugggestion? | A*******s 发帖数: 3942 | 2 not sure if there is a better way but i do it in such a stupid way:
%let charstr=1 3 6 7;
%let i=1;
%do %while (%scan(&charstr, &i) ne );
%let j=(%scan(&charstr, &i);
%let i=%eval(&i+1);
......
%end;
【在 s*******d 的大作中提到】 : How to assign a bunch of numbers in a %do loop in a macro? : %do i=1, 3, 6, 7; : .... : %end; : It doesn't work in SAS : Any sugggestion?
| d*******1 发帖数: 854 | 3 Yes,I cannot understand why sas does not make this simple thing easy. Like what'Re does
【在 A*******s 的大作中提到】 : not sure if there is a better way but i do it in such a stupid way: : %let charstr=1 3 6 7; : %let i=1; : %do %while (%scan(&charstr, &i) ne ); : %let j=(%scan(&charstr, &i); : %let i=%eval(&i+1); : ...... : %end;
| l*********s 发帖数: 5409 | 4 this is not easy to implement in text-based macro language
what'Re does
【在 d*******1 的大作中提到】 : Yes,I cannot understand why sas does not make this simple thing easy. Like what'Re does
| h**********e 发帖数: 44 | 5 First create a dataset:
data index;
input i;
datalines;
1
3
6
7
run;
Then
%do j=1 &to 4;
data a;
set index (obs=&j);
call symput('i',i);
run;
/*do whatever you want to do with &i here*/
...
%end;
This is what I usually do this kind of work. Remember macro in SAS is not as
easy as function in C. SAS is dataset oriented in most of the cases.
【在 s*******d 的大作中提到】 : How to assign a bunch of numbers in a %do loop in a macro? : %do i=1, 3, 6, 7; : .... : %end; : It doesn't work in SAS : Any sugggestion?
|
|