Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Add


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Add
Date   Mon, 15 Feb 2010 20:28:20 +0100

<>

I assume you meant "5 if the 5 digits number end in a(n) ODD number." ? If
so:

*******
clear*

input code 
12323
10230
45321
65098
54397
end

compress
list, noo

replace code=10*code+5*mod(code,2)

list, noo
*******


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tiago Fonseca
Sent: Montag, 15. Februar 2010 20:20
To: statalist@hsphsun2.harvard.edu
Subject: st: Add

How can I add a number to a real by its parity?
I have a 5 digits code and I want to generate 6 digits code where the 
last digit is:
0 if the 5 digits number end at 0 or a even number
5 if the 5 digits number end in a even number.

Regards,
Tiago Fonseca
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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