Discussions about editing and cleaning data
leulae
Posts: 46 Joined: December 16th, 2016, 5:51 am
Post
by leulae » February 1st, 2018, 1:48 am
Dear All,
It would be grateful, if anyone suggests me a method to loop though variables as we did in SPSS
Sample Code:(SPSS)
DO REPEAT V= V1 TO V4 / W = W1 TO W4 / X = X1 TO X4 / Y = Y1 TO Y4.
COMPUTE X = V + W.
COMPUTE Y = V - W.
END REPEAT.
Leulae
leulae
Posts: 46 Joined: December 16th, 2016, 5:51 am
Post
by leulae » February 1st, 2018, 9:05 am
Thanks Josh for your reply,
This is not kind of Roster or array processing (Looping with same variable eg. age(i) )
If we have Data file with variable name age, sex, maritalstatus,…..,nationality as near columns, in SPSS we can loop from age to nationality, I am seeking same in Cspro
Thanks
Leulae
josh
Posts: 2399 Joined: May 5th, 2014, 12:49 pm
Location: Washington DC
Post
by josh » February 1st, 2018, 9:27 am
No. That is not possible in CSPro.
leulae
Posts: 46 Joined: December 16th, 2016, 5:51 am
Post
by leulae » February 1st, 2018, 9:32 am
Thank you Josh,
Need to process all items (variables) from one place beginning to end, any hint?
Leulae
josh wrote: No. That is not possible in CSPro.
josh
Posts: 2399 Joined: May 5th, 2014, 12:49 pm
Location: Washington DC
Post
by josh » February 1st, 2018, 9:35 am
Maybe if you tell us more generally what you trying to do we can come up with something.
Gregory Martin
Posts: 1803 Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC
Post
by Gregory Martin » February 26th, 2018, 2:23 pm
This isn't the cleanest code, but you can use getvalue/setvalue. For example:
do numeric ctr = 1 while ctr <= 4
setvalue (maketext ("X%d" ,ctr),getvalue (maketext ("V%d" ,ctr) + getvalue (maketext ("W%d" ,ctr));
setvalue (maketext ("Y%d" ,ctr),getvalue (maketext ("V%d" ,ctr) - getvalue (maketext ("W%d" ,ctr));
enddo ;