[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: removing "first letters"
This is good, but not I would say optimal.
Suppose for example your strings really
start with a space in some or all observations.
Suppose you haven't spotted that a few observations
don't follow this pattern.
If so, you will have messed up your data.
Even if not,
replace varname = subinstr(varname, "www.", "", 1)
is a more focused approach to the problem. Yet
another small advantage is that your purpose will
be clearer in do or log files.
> try the -substr- function:
> gen newvarname = substr(original_variable, 5, .)
> briefly, generate a new variable equal to the contents of the original
> variable, minus the first four characters (e.g. the "www.").
> type -findit substr- for more information.
> > I have a variable with web addresses and all the entries in
> this variable
> > start with "www.". Is there an easy way of removing the
> "www." from the
> > beginning of all entries?
* For searches and help try: