由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS macro variable resolution question
相关主题
大家说说这是电脑的错还是SAS的错sas question!!!
问个sas adv的问题为啥我的宏不被解释--SYMBOLGEN
Help: SAS code请教一个SAS问题
SAS macro Debugquestion on SAS macro (many thanks!!)
与Macro相关的字符函数question about using sas macro variable and do loop
SAS Macro 问题请教 。。。请教两个SAS的问题
问大家一个Macro的问题请教SAS macro - please help, still not resolved
请教个&的问题2 sas questions
相关话题的讨论汇总
话题: fruit话题: macro话题: variable话题: sas话题: resolved
进入Statistics版参与讨论
1 (共1页)
t**i
发帖数: 688
1
I have a sas macro variable with the variable name fruit, suppose it can be
resolved to anything but the char string fruit itself.
I have other sas macro variables called fruit1, fruit2, ..., fruit5, ...,
and these variables are to be resolved as apple, orange, etc.
Now I want to keep chosen columns, say apple, orange, banana, but I have had
a problem to have the "concatnated" macro variable correctly resolved?
I have tried
&fruit&i
&&fruit&i
&&&fruit&i
&.fruit&i
&&.fruit&i
None above works.
Doe
l***a
发帖数: 12410
2
&&fruit&i should work

be
had

【在 t**i 的大作中提到】
: I have a sas macro variable with the variable name fruit, suppose it can be
: resolved to anything but the char string fruit itself.
: I have other sas macro variables called fruit1, fruit2, ..., fruit5, ...,
: and these variables are to be resolved as apple, orange, etc.
: Now I want to keep chosen columns, say apple, orange, banana, but I have had
: a problem to have the "concatnated" macro variable correctly resolved?
: I have tried
: &fruit&i
: &&fruit&i
: &&&fruit&i

t**i
发帖数: 688
3
options symbolgen mprint mlogic ;
Data b;
Input ID apple orange banana papaya ;
Datalines;
1 1 2 3 4
2 5 6 7 8
;
Run;
%let fruit = good ;
%let fruit1 = apple ;
%let fruit2 = orange ;
%let fruit3 = banana ;
data a;
set b;
do I = 1 to 3;
keep &&fruit&i ;
end;
run;
t**i
发帖数: 688
4
49 data a;
50 set b;
51 do I = 1 to 3;
SYMBOLGEN: && resolves to &.
WARNING: Apparent symbolic reference I not resolved.
SYMBOLGEN: Unable to resolve the macro variable reference &i
SYMBOLGEN: Macro variable FRUIT resolves to good
SYMBOLGEN: Unable to resolve the macro variable reference &i
52 keep &&fruit&i ;
NOTE: Line generated by the macro variable "I".
52 good&
-
22
200
WARNING: Apparent symbolic reference I not resolved.
ERROR 22
l***a
发帖数: 12410
5
.... log info tells you clearly the error. there is no &i in your code. when
you do this way you have to make it a macro

【在 t**i 的大作中提到】
: options symbolgen mprint mlogic ;
: Data b;
: Input ID apple orange banana papaya ;
: Datalines;
: 1 1 2 3 4
: 2 5 6 7 8
: ;
: Run;
: %let fruit = good ;
: %let fruit1 = apple ;

S******y
发帖数: 1123
6
This should do --
1 (共1页)
进入Statistics版参与讨论
相关主题
2 sas questions与Macro相关的字符函数
sas and environmental variablesSAS Macro 问题请教 。。。
SAS help : The scope of macro variables问大家一个Macro的问题
靠,这个哪错了?请教个&的问题
大家说说这是电脑的错还是SAS的错sas question!!!
问个sas adv的问题为啥我的宏不被解释--SYMBOLGEN
Help: SAS code请教一个SAS问题
SAS macro Debugquestion on SAS macro (many thanks!!)
相关话题的讨论汇总
话题: fruit话题: macro话题: variable话题: sas话题: resolved