For the below sample data, I would like to subtract X1 from X5 and save it as X13. Likewise, I would like to subtract X2 from X6 and save it as X14. IK have tried the below loop but it does not work. Thanks for your help.
NM
Code:
forval i = 1/8 { gen X`i+12'=X`i'-X`i+4' }
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12) 22.573143 7.601128 30.17427 .7480924 16.524061 9.962753 26.486814 .6238599 21.069393 14.272256 35.34165 .5961633 21.19807 7.195382 28.39345 .7465831 15.5447 9.462714 25.007414 .6216037 19.923904 13.46682 33.390724 .5966898 19.824026 6.810086 26.63411 .7443097 14.550502 8.996266 23.54677 .6179405 18.765072 12.68481 31.44988 .5966659 18.467472 6.435489 24.90296 .7415773 13.565183 8.549612 22.114796 .6133985 17.60442 11.917387 29.521807 .5963192 17.13954 6.066377 23.20592 .7385849 12.603266 8.115009 20.718275 .6083164 16.45005 11.159567 27.60962 .5958087 15.848076 5.700288 21.548365 .7354653 11.67356 7.688297 19.361856 .6029153 15.30798 10.408947 25.716927 .5952492 end
0 Response to Generating a new var using loops
Post a Comment