Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gegen normalize does not realize that a new variable shall be created #74

Closed
felixholub opened this issue May 3, 2021 · 1 comment
Closed
Assignees
Labels

Comments

@felixholub
Copy link

Describe the bug
When using gegen with normalize, a target exists error is returned if a variable beginning with the same name exists.
With mean, for example, this does not happen.

Code Sample

sysuse auto, clear

// works fine with mean
gegen mpg_aa = mean(mpg)
gegen mpg_a = mean(mpg)

// does not work with normalize
gegen mpg_bb = normalize(mpg)
// throws arrow as it thinks that mpg_b refers to mpg_bb
gegen mpg_b = normalize(mpg), verbose bench(3)
. sysuse auto, clear
(1978 Automobile Data)

. // works fine with mean
. gegen mpg_aa = mean(mpg)
. gegen mpg_a = mean(mpg)

. // does not work with normalize
. gegen mpg_bb = normalize(mpg)

. // throws arrow as it thinks that mpg_b refers to mpg_bb
. gegen mpg_b = normalize(mpg), verbose bench(3)
Parsed by variables; .002 seconds
gstats_transform: target mpg_b exists without replace
r(198);

Version info

  • OS: Windows 10
  • Version: 1.7.5
@mcaceresb mcaceresb self-assigned this May 3, 2021
@mcaceresb mcaceresb added the bug label May 3, 2021
@mcaceresb
Copy link
Owner

@felixholub As a quick fix, add set varabbrev off

I legitimately cannot remember what issues varabbrev caused that effected me to comment out this line. I am personally very strongly against varabbrev but have had to deal with it somewhat since Stata has it turned on by default.

I believe the fix is to change the way I check for whether a variable exists from a failure of confirm var to a success of confirm new var, but won't have time to test it for a bit.

mcaceresb added a commit that referenced this issue Aug 28, 2021
Features

- Added `gglm` to estimate GLM models, including `logit`.

Bug Fixes

- Closes #78: if now passed raw/in double-quotes throughout the pipeline
- Closes #75: gunique returns 0s in r() when there are no obs
- Closes #74: gstats transform parses abbreviated targets
- Closes #72: Warning for gegen expressions without by group
- Fixed GLM issues generating de-meaned variables
- Fixed gegen nunique with multiple inputs
- Fixed bug in `gpoisson` where internal weights not copied correctly in loop.
- Various fixes to the docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants