a********a 发帖数: 3176 | 1 A macro variable can be: &sites =site1 site3 site6
or &sites =site8
or &sites =site2 site5 site7 site8,
or any of the 8 site combinations.
I'd need to create a macro variable that just contains the number of the
site, i.e
&siten=1, 3, 6
or &siten=8
or &siten=2, 5, 7, 8
in order to be used in a do loop later to select only the included sites.
This is revising an existing macro that assu | D******n 发帖数: 2836 | 2 u mean u wanna change siten's value according to sites ?
【在 a********a 的大作中提到】![](/moin_static193/solenoid/img/up.png) : A macro variable can be: &sites =site1 site3 site6 : or &sites =site8 : or &sites =site2 site5 site7 site8, : or any of the 8 site combinations. : I'd need to create a macro variable that just contains the number of the : site, i.e : &siten=1, 3, 6 : or &siten=8 : or &siten=2, 5, 7, 8 : in order to be used in a do loop later to select only the included sites.
| a********a 发帖数: 3176 | 3 Thanks for having taken a look.
The macro was first written to assume that &site=site1 site2 ....site&n
consecutively.
And it later used do x=1 to &n.
Now I saw that sometimes it was &site=site1 site6 only, so 'do x=1 to 6'
doesn't work, and I'd like to make a macro variable that have value of 1 and
6 only, so that I can use 'do x=1,6'.
Does this make it cleaer?
Or is there any other way to get around this?
【在 D******n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : u mean u wanna change siten's value according to sites ?
| w***y 发帖数: 114 | 4 I donot understand you clearly, anyway, you should try &&site&i to get the
value,like below, Good luck.
%macro xx;
%do i=1 %to n;
&&site&i;
%mend; | x**m 发帖数: 941 | 5 If you know which site is what you need, just put them in different site
list and use some macro condition codes. For example:
%let list1=%str((1,6));
...
%do i=1 %to n;
%if &i in &list1 %then %do;
....
%end;
%if &i in &list2 %then %do;
....
%end; | a********a 发帖数: 3176 | 6 Thanks much! This is helpful, which pompted me to do something similar and
it worked:
1. get site count:
%let site_cnt=%sysfunc(countw(&impsints));
%put There are &site_cnt sites in the string "&impsints";
2. get site number to be indexed:
%do z= 1 %to &site_cnt;
%let realsite = %scan(&impsints, &z);
%let nsite_1 = %substr(&realsite, 5, 1);
%let nsite = %substr(&realsite, 5, 1);
%if &z>1 %then %do;
%let nsite = !%substr(&reals
【在 x**m 的大作中提到】![](/moin_static193/solenoid/img/up.png) : If you know which site is what you need, just put them in different site : list and use some macro condition codes. For example: : %let list1=%str((1,6)); : ... : %do i=1 %to n; : %if &i in &list1 %then %do; : .... : %end; : %if &i in &list2 %then %do; : ....
| D******n 发帖数: 2836 | 7 how about this?
%let sites =site1 site3 site6;
data _null_;
siteno = substr(tranwrd("&sites","site",","),2);
call symput("siteno",siteno);run;
and
【在 a********a 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Thanks much! This is helpful, which pompted me to do something similar and : it worked: : 1. get site count: : %let site_cnt=%sysfunc(countw(&impsints)); : %put There are &site_cnt sites in the string "&impsints"; : 2. get site number to be indexed: : %do z= 1 %to &site_cnt; : %let realsite = %scan(&impsints, &z); : %let nsite_1 = %substr(&realsite, 5, 1); : %let nsite = %substr(&realsite, 5, 1);
|
|