I have a dataset which I export with command outsheet into a csv-file. There are some rows which breaks line at a certain place. Using a hexadecimal editor I could recognize the control character for line feed "0a" in the record. The value of the variable producing the line break shows visually (in Stata) only 5 characters. But if I count the number of characters:

gen xlen = length(x)

I get 6. I could write a Perl programm to get rid of this problem but I prefer to remove the control characters in Stata before exporting (for example using regexr()). Does anyone have an idea how to remove the control characters?

有帮助吗?

解决方案

The char() function calls up particular ASCII characters. So, you can delete such characters by replacing them with empty strings.

replace x = subinstr(x, char(10), "", .) 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top