I'm trying to do a simple change here, that is, to remove all leading spaces in one observation using the command strtrim() function in a loop across several of my variables. However, for a reason I don't know, the code just won't work for all of them. Please consider this simple example :
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str16 FW str22 FX str33 FY " [xxx]" " [yyy]" " [zzz]" end
Code:
foreach var of varlist FW-FY { replace `var' = strtrim(`var') }
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str16 FW str22 FX str33 FY "[xxx]" " [yyy]" "[zzz]" end
Code:
foreach var of varlist FW-FY { replace `var' = strtrim(`var') replace `var' = subinstr(`var', uchar(160), "", .) }
0 Response to In a loop, strtrim() won't work in some of my variables
Post a Comment