由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS macro variable help
相关主题
[合集] 请教一个sas问题urgent help using sas or R for data management
继续问个MACRO VARIABLE问题。。。一个关于macro的问题,多谢。
Help: SAS code急问:SAS batch submission with macro variable
SAS help : The scope of macro variablesSAS Technical Interview Questions
急问一个SAS 的常见问题一道sas题 在线求解 50个包子答谢 急啊
batch?SAS Macro 问题请教 。。。
求助关于sas macro 中的if- then语句sas 代码问题
why this error in %if statement问一个SAS macro的问题
相关话题的讨论汇总
话题: macro话题: site话题: sites话题: siten话题: variable
进入Statistics版参与讨论
1 (共1页)
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 的大作中提到】
: 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 的大作中提到】
: 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 的大作中提到】
: 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 的大作中提到】
: 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);

1 (共1页)
进入Statistics版参与讨论
相关主题
问一个SAS macro的问题急问一个SAS 的常见问题
Re: SAS help : How to use Macro to select procedursbatch?
sas 中如何给一个variable 加密?求助关于sas macro 中的if- then语句
Help! A data step problemwhy this error in %if statement
[合集] 请教一个sas问题urgent help using sas or R for data management
继续问个MACRO VARIABLE问题。。。一个关于macro的问题,多谢。
Help: SAS code急问:SAS batch submission with macro variable
SAS help : The scope of macro variablesSAS Technical Interview Questions
相关话题的讨论汇总
话题: macro话题: site话题: sites话题: siten话题: variable