Hi, I'm trying to concat two numeric variables whit the egen command, I know when it is used a string variable results, but, when I try to destring a "non-numeric characters" appears and the variable isn't replace. I need to do math operations with this variable so I can't leave it as a string. If you know the solution, I would be very grateful for your help.
e.g. I got two weight variables p1005peso_2 for an integer number and p1005peso_2 for a fraction of the weight
+----------+ +----------+
| p1005p~2 | | p100~o_1 |
|----------| |----------|
1. | 103 | 1. | 6 |
2. | 54 | 2. | 9 |
3. | 62 | 3. | 8 |
4. | 61 | 4. | 5 |
5. | 70 | 5. | 4 |
+----------+ +----------+
**egen peso_con = concat(p1005peso_2 p1005peso_1), punct(.)
. list peso_con in 1/5
+----------+ this is how I need the variable shown, but numeric
| peso_con |
|----------|
1. | 103.6 |
2. | 54.9 |
3. | 62.8 |
4. | 61.5 |
5. | 70.4 |
+----------+
in the missing values shows ". . ."
** destring peso_con, replace
peso_con: contains nonnumeric characters; no replace
Related Posts with egen for numeric variables
generate a value indicating how many time a situation happens before the specific dateHello everyone in the community! Sorry to have some problems with the same data again , thanks agai…
Matching Actions to YearsI have to different databases. Database 1 has executive actions in specific years, but this is not c…
Kaplan Meier survival description output - no median resulthi all, I am using Stat 16 on Mac. I am calculating Kaplan Meier survival curves for 2 groups of pat…
preparing data for propensity score matchDear All, I want to analyze if the gain in public health insurance due to this policy (Medicaid exp…
rename variablesI am poor at Stata coding. I would like to rename from "logind1-logind84" to " logcoefstandind101, l…
Subscribe to:
Post Comments (Atom)
0 Response to egen for numeric variables
Post a Comment