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 | |
|