/*HELP! I have a list of variables that were created using the VECTOR command. I need to rename these variables so that the names are more meaningful. The dataset looks something like this (I'm in the middle of a transformation from cross- sectional to longitudinal data setup): ID relation height1 height2 ... height15 weight1 weight2 ... weight15 ... 1 mother 67 150 1 father 70 185 . 1 sibling13 62 135 I need to rename all the variables, so that the value of the relation variable is reflected in the appropriate name; in other words the varnames should look like this (excuse the long variable names, they are for illustration only; they will have 8 characters in the real dataset): ID heightmother heightfather ... heightsibling13 weightmother weightfather... Considering there are over 150 variables that I have to rename, I'd rather not have to rename everything by hand. Is there any way I can use a DO REPEAT syntax to create a loop that will rename everything for me? I would appreciate any help I can get on this one! Thanks, Sylvia */. ************************************. * This is Ray's answer posted on July 15,2000 to the usenet. *Define the variable names. NEW FILE. DATA LIST LIST /id(F8). BEGIN DATA END DATA. VECTOR height(15F8) weight(15F8) test(15F8). set mprint=on. DEFINE !rename (!POS=!CMDEND) !DO !var !IN (!1) !IF (!LENGTH(!var)<6) !THEN !LET !var2=!var !ELSE !LET !var2=!SUBSTR(!var,1,5) !IFEND RENAME VARIABLE (!CONCAT(!var,'1')=!CONCAT(!var2,'mdr')). RENAME VARIABLE (!CONCAT(!var,'2')=!CONCAT(!var2,'ftr')). !DO !cnt=1 !TO 13 RENAME VARIABLE (!CONCAT(!var,!LENGTH(!CONCAT(!BLANK(!cnt),'xx' )))=!CONCAT(!var2,'s',!cnt)). !DOEND !DOEND !ENDDEFINE. * Call the macro. !rename height weight test.