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

st: string manipulation


From   asad <[email protected]>
To   [email protected]
Subject   st: string manipulation
Date   Sat, 17 May 2003 15:25:20 -0700 (PDT)

Hello,

I need to create a string ID (var1) by preserving the
blanks, using numeric variables id01 and id02:

     id01	id02
     1	 	688
     1     	  8
     1   	 88

I need to obtain Var1:
	Var1	varn1 	        varn2
     1 688  	.1.688  	1688
     1   8  	.1...8  	  18
     1  88  	.1..88		 188


If I do the following:

g str2 id01s=string(id01)
g str4 id02s=string(id02)
replace  id02s=cond(length(id02s)==1,""+""+ id02s,
id02s)
replace  id02s=cond(length(id02s)==2,""+ id02s, id02s)
g str6 varn2=id01s+ido2s
; I GET VARN2.

AND IF I put ".", i get varn1.

I GET VARN1. ANY IDEA ON HOW TO GET VAR1?

Many thanks. Asad.


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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