asad
> 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?
I guess you want something like (this is one line): 
gen str6 var1 = " " + string(id01) 
	+ substr("     ",1,4 - length(string(id02)) 
	+ string(id02) 
In short, a space is a character and you can refer to it 
as " ". 
Nick 
[email protected] 
*
*   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/