Hi, I have a variable name "age" However, there are values like 6.01. How will I convert all 6.01 to just 6? Thank you.
-
Login or Register
- Log in with
. clear
. set more off
.
. input x
x
1. 6
2. 6.2
3. 6.5
4. 6.7
5. 7
6. end
.
. gen y1 = floor(x)
. gen y2 = ceil(x)
. gen y3 = round(x)
.
. describe
Contains data
obs: 5
vars: 4
size: 80
----------------------------------------------------------------------------
storage display value
variable name type format label variable label
----------------------------------------------------------------------------
x float %9.0g
y1 float %9.0g
y2 float %9.0g
y3 float %9.0g
----------------------------------------------------------------------------
. gen int y1 = floor(x)
. gen int y2 = ceil(x)
. gen int y3 = round(x)
.
. describe
Contains data
obs: 5
vars: 4
size: 50
----------------------------------------------------------------------------
storage display value
variable name type format label variable label
----------------------------------------------------------------------------
x float %9.0g
y1 int %8.0g
y2 int %8.0g
y3 int %8.0g
----------------------------------------------------------------------------
Comment