Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: right justifying strings, left padding strings with zeros

From   Clare L Maxwell <>
To   statalist <>
Subject   st: right justifying strings, left padding strings with zeros
Date   Tue, 22 Nov 2005 21:23:06 -0600

Hello to members of the Stata list. Thank you in advance for having a look at this.

I have a six-column subject identifier coming into Stata from an ASCII file that looks like the following:

B 1
B 120
CCH 23
UW 23
UW 232

I want to read in and manipulate these 6 columns so that in the end, I have a str6 variable that looks like this:


That is, the first three columns have been right justified and the last three columns have been left-padded with zeros. I have tried various options, but so far, not much luck. I was considering reading them in as six str1 variables and putting things together sort of by brute force, but I thought I'd ask first. Any suggestions on good string manipulations for this problem?

Thank you very much.

Yours truly,
Clare Maxwell

* For searches and help try:

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