m****r 发帖数: 202 | 1 My question is
if the variable has the suffix _12, the sum can't be shorted as
(of TR01_12-TR28_12) or
(of TR01_12--TR28_12).
I have to present all the variables like the following
all = sum ( of TR01 - TR33 );
all_12=sum(TR01_12,TR02_12,TR03_12,TR04_12,TR05_12,TR06_12,TR07_12,TR08_12,
TR09_12,TR10_12
TR11_12,TR12_12,TR13_12,TR14_12,TR15_12,TR16_12,TR17_12,TR18_12,TR19_12,TR20
_12
TR21_12,TR22_12,TR23_12,TR24_12,TR25_12,TR26_12,TR27_12,TR28_12);
Do you have a better way for all_12 ?
Thanks | s******r 发帖数: 1524 | 2 I am lazy and stupid and have no idea of smart way.
I would use macro to do that.
TR20
【在 m****r 的大作中提到】 : My question is : if the variable has the suffix _12, the sum can't be shorted as : (of TR01_12-TR28_12) or : (of TR01_12--TR28_12). : I have to present all the variables like the following : all = sum ( of TR01 - TR33 ); : all_12=sum(TR01_12,TR02_12,TR03_12,TR04_12,TR05_12,TR06_12,TR07_12,TR08_12, : TR09_12,TR10_12 : TR11_12,TR12_12,TR13_12,TR14_12,TR15_12,TR16_12,TR17_12,TR18_12,TR19_12,TR20 : _12
| T*******I 发帖数: 5138 | 3 为什么你不将你的变量名改成一下序列:
(of TR12_01-TR12_28) ?????
【在 m****r 的大作中提到】 : My question is : if the variable has the suffix _12, the sum can't be shorted as : (of TR01_12-TR28_12) or : (of TR01_12--TR28_12). : I have to present all the variables like the following : all = sum ( of TR01 - TR33 ); : all_12=sum(TR01_12,TR02_12,TR03_12,TR04_12,TR05_12,TR06_12,TR07_12,TR08_12, : TR09_12,TR10_12 : TR11_12,TR12_12,TR13_12,TR14_12,TR15_12,TR16_12,TR17_12,TR18_12,TR19_12,TR20 : _12
| h********o 发帖数: 103 | 4 If your variables appear in the order of TR01_12, TR02_12,...,TR12_12 in the
data set, you can use Name Range Lists as
all = sum(of tr01_12 -- tr12_12); | m****r 发帖数: 202 | 5 Thank you for your kindly reply.
1. I have baseline, 12mon, 18mon variables, that's way the variables are
named tr01-tr28,tr01_12-tr28_12,tr01_18-tr28_18
2. Macro can't be used here
3.when I use "all = sum(of tr01_12 - tr28_12);" the log said"
ERROR: Alphabetic prefixes for enumerated variables (tr01_12 - tr28_12)
are different.
ERROR 71-185: The SUM function call does not have enough arguments."
4.These variables are physically seperated,so I can't use
"all = sum(of tr01_12 -- tr28_12);"
Thank you again | h********o 发帖数: 103 | 6 Try following code to change variable names then use SUM funciton.
===========
%MACRO RENAME(INDEX);
RENAME
%DO I = 1 %TO 9;
TR0&I._&INDEX = TR&INDEX._0&I
%END;
%DO I = 10 %TO 28;
TR&I._&INDEX = TR&INDEX._&I
%END;
%MEND;
DATA TEST;
SET yourdata;
%RENAME(12);
%RENAME(18);
RUN; | l****u 发帖数: 529 | 7 Under such circumstance, you can rearrange the sequence of your variables,
just making no separations between tr01_12--tr28_12. |
|