BookmarkSubscribe
Choose Language Hide Translation Bar
lilysecret
Community Trekker

Appending the "SPSS Name" property problem

Hello,

I'm trying to append the "SPSS Name" property for all columns in my dataset with the string "_R1". This loop works until line 5; the result is that all the SPSS Names get changed to SNname - not the value of the variable, but the text SNname. I've tried putting it in quotes and I've tried using the Name() function and it still didn't work. I'm hoping someone can tell me the syntax I need to use to get this to work. I've attached an abbrievieted file of my data. Thanks!

 

 

For( i = 1, i <= N Cols( dt ), i++,
	cName = Column(dt,i) << Get Property("SPSS Name");
	SNname = cName|| "_R1";
	show(SNname);
	Column( dt, i ) << Set Property("SPSS Name", SNname );
);
0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
cwillden
Super User

Re: Appending the "SPSS Name" property problem

Set Property() is not going to evaluate SName.  You probably need to parse SName before evaluating that line.  Try this:

Eval(Parse(Eval Insert("\[Column( dt, i ) << Set Property("SPSS Name", ^SNname^ )]\")));
-- Cameron Willden
3 REPLIES 3
cwillden
Super User

Re: Appending the "SPSS Name" property problem

Set Property() is not going to evaluate SName.  You probably need to parse SName before evaluating that line.  Try this:

Eval(Parse(Eval Insert("\[Column( dt, i ) << Set Property("SPSS Name", ^SNname^ )]\")));
-- Cameron Willden
txnelson
Super User

Re: Appending the "SPSS Name" property problem

You need to perform an eval() on the variable SName.

For( i = 1, i <= N Cols( dt ), i++,
	cName = Column(dt,i) << Get Property("SPSS Name");
	SNname = cName|| "_R1";
	show(SNname);
	Column( dt, i ) << Set Property("SPSS Name", eval(SNname) );
);
Jim
Highlighted
cwillden
Super User

Re: Appending the "SPSS Name" property problem

This is more elegant.  Nice add Jim.

-- Cameron Willden
0 Kudos