s********8 发帖数: 50 | 1 Q29B4B-Q29B30B are not next to each other in dataset
and Q29B4B Q29B5B Q29B6B----Q29B30B need to be an array .
do I have to put one by one ?
I alreasy tried Q29B4B-Q29B30B , it didn't work.
ask for help ! | k*******a 发帖数: 772 | 2 %macro names;
%do i=4 %to 30;
Q29B&i.B
%end;
%mend;
data a;
input %names;
....... | s********8 发帖数: 50 | 3 thanks !
but what I want is put them in an array.
Array abc(*) Q29B4B--Q29B30B (if they are next to each other in dataset.
and
Array abc(*) Q29B4B-Q29B30B (in SAS, it didn't work out)
so I am thinking if there is a smart way to do instead of
Array abc(*) Q29B4B Q29B5B Q29B6B,,,,,,,,,,,Q29B30B (type one by one)
any hint?
thanks
【在 k*******a 的大作中提到】 : %macro names; : %do i=4 %to 30; : Q29B&i.B : %end; : %mend; : data a; : input %names; : .......
| k*******a 发帖数: 772 | 4 That's same thing
just replace those names with %names
if you use the macro
【在 s********8 的大作中提到】 : thanks ! : but what I want is put them in an array. : Array abc(*) Q29B4B--Q29B30B (if they are next to each other in dataset. : and : Array abc(*) Q29B4B-Q29B30B (in SAS, it didn't work out) : so I am thinking if there is a smart way to do instead of : Array abc(*) Q29B4B Q29B5B Q29B6B,,,,,,,,,,,Q29B30B (type one by one) : any hint? : thanks
| d*******o 发帖数: 493 | 5 %let lastletter = B;
Array abc(*) Q29B4&lastletter--Q29B30&lastletter;
| m*****a 发帖数: 658 | 6 Array abc(*) Q29B:;
select all the variables initial with Q29B.
Hope it helps. | s********8 发帖数: 50 | 7 Thanks for thinking for it , it is a good trial.
but after I tried the code below, I didn;t think it worked.
data Farray;
length Q29B4B A Q29B5B B Q29B6B C Q29B7B D Q29B8B E Q29B9B F Q29B10B G
Q29B11B H Q29B12B I Q29B13B G Q29B14B K Q29B15B $8;
%let lastletter = B;
Array Ftesta(*) Q29B4&lastletter--Q29B15&lastletter;
Array Ftestb(*) Q29B4&lastletter-Q29B15&lastletter;
K=DIM(Ftesta);
P=DIM(Ftestb);
put K= P=;
run;
in LOG K=22 instead of 12;
and P can not get any value since
ERROR: Missing numeric suffix on a numbered variable list (Q29B4B-Q29B15B).
I will try the other way .
invite you all for this game , :).
Thanks!
【在 d*******o 的大作中提到】 : %let lastletter = B; : Array abc(*) Q29B4&lastletter--Q29B30&lastletter; :
|
|