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

Feature request - greshape wide - separate #69

Closed
elektrotiko opened this issue Oct 4, 2019 · 3 comments
Closed

Feature request - greshape wide - separate #69

elektrotiko opened this issue Oct 4, 2019 · 3 comments

Comments

@elektrotiko
Copy link

elektrotiko commented Oct 4, 2019

Hi

There is a very slow command in Stata named "separate". What is does is creating new variables containing values from varname.

It would be great to have a similar option for greshape wide , separate that does the same thing, i.e. when reshaping to wide also taking the string value from previous variable and making in the variable label of the new variables in question.

Is that possible?

P.S. Note that some string [aliases] may contain leading or trailing blanks, which would require trimming the string before making the new variable labels for wide-reshaped ones.

Regards

@mcaceresb
Copy link
Owner

So, th behavior of separate in general seems to me quite different to reshape.

You just mean the part where it appends to the variable label a note saying "variable = value"?

@elektrotiko
Copy link
Author

elektrotiko commented Oct 6, 2019

Yes, that is correct. I want to be able to greshape wide and set new variable labels from original string values.

mcaceresb added a commit that referenced this issue Jan 27, 2020
Features

- In `gregress` (including `givregress` and `gpoisson`) collinear
  columns are now dropped (LDL' decomposition).

- `gegen shift, shiftby(#)` and `gstats transform (shift #)` are available
  to compute lags (negative `#`) and leds (positive `#`).

- Adds `gini`, `gini dropneg`, `gini keepneg` to `gcollapse`, `gegen`,
  and `gstats tab`.

- Adds `cumsum`, `cumsum +/-`, and `cumsum +/- varname` to `gstats transform`;
  options can also be passed to `cumsum` globally via `cumby()`

- Closes #69. `greshape wide/spread` now allows `labelformat()` for
  custom variable labels (only when a single variable is passed to
  `key()/j()`). The default is `#keyvalue# #stublabel#`.  Available
  placeholders are `#stubname#`, `#stublabel#`, `#keyname#`,
  `#keylabel#`, `#keyvalue#`, and `#keyvaluelabel#`

Enhancements

- Closes #68. `gegen` now allows `by:` prefix when calling a
  `gstats transform` function (this is only allowed because these calls
  already require single-variable input, so the `by:` prefix should not
  present an issue when calling the function).

- In `givgregress`
    - Values to missing if model is not identified (not enough instruments).
    - `hdfe` no longer saves projected vars.

- Collinearity and singularity checks in regression models

- Removed rowmajor option from `gregress`

Bug Fixes

- In `gquantiles`, data was read incorrectly with `by()` and `weights`
  if `xtile` was not requested. In particular, the data was copied as if
  the target had only one column, but since weights need to be included,
  the target has two columns. This was fixed.

- Fixes bug in `greshape, dropmiss` where if the number of remaining
  observations is lower than the observations in memory, `set obs` would
  be run, resulting in an error. Now `keep in` is run for that case.
@mcaceresb
Copy link
Owner

This is now available. To imitate separate labeling you can do:

sysuse auto, clear
local labelformat labelformat(#stubname#, #keyname# == #keyvaluelabel#)
greshape wide mpg, by(make) key(foreign) `labelformat'
desc mpg*

However, you can use any combination of placeholders. For instance,

sysuse auto, clear
local labelformat labelf(#stublabel#; #keylabel# == #keyvaluelabel#)
greshape wide mpg, by(make) key(foreign) `labelformat'
desc mpg*

Placeholders available are #stubname#, #stublabel#, #keyname#, #keylabel#, #keyvalue#, and #keyvaluelabel#.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants