Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: cut string variables

From   "Ada Ma" <>
Subject   Re: st: cut string variables
Date   Mon, 22 May 2006 21:51:29 +0100

If you have a lot of repeated values in your word variable, you might
consider turning the string variable into a numeric variable with

encode word, gen(word2)

It would make the data set smaller (so it will load faster), and the
label word2 would keep  what your original variable says.

On 5/22/06, Richard Goldstein <> wrote:
use the substr function, as in

gen str word2=substr(word1,1,50)

to get the first 50 characters of word1 into the new variable called word2


susanne neckermann wrote:
> Hello,
> I cannot open a data set in my intercooled Stata version because one of
> the variables is a string with 102 characters and intercooled Stata only
> allows for 80.
> I can open the data set at a friend's computer who has the full version
> of stata. But we have not found out, what the command is to cut the
> length of this particular string. so that we can change the data set and
> I can work with it on my computer.
> It would be o.k., if only the first 50 characters or so remain.
> Can you help?
> Thank you very much.
> Greetings from Switzerland,
> Susanne

*   For searches and help try:

Ada Ma
Research Fellow
Health Economics Research Unit
University of Aberdeen, UK.
Tel: +44 (0) 1224 553863
Fax: +44 (0) 1224 550926

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index