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

row-wise if #20

Open
matthieugomez opened this issue Oct 6, 2021 · 2 comments
Open

row-wise if #20

matthieugomez opened this issue Oct 6, 2021 · 2 comments

Comments

@matthieugomez
Copy link
Contributor

matthieugomez commented Oct 6, 2021

It seems like it would be nicer to have if as a row-wise operation.

That is, instead of:

d"generate :x = :SepalWidth + :PetalLength if :PetalLength .> 1.3"
d"bysort :Species (:SepalLength) : generate :x = :SepalWidth + :PetalLength if :PetalLength .> 1.3"
d"bysort :Species (:SepalLength) : egen :x = mean(:PetalWidth) if :SepalWidth .< 3.4"

have

d"generate :x = :SepalWidth + :PetalLength if :PetalLength > 1.3"
d"bysort :Species (:SepalLength) : generate :x = :SepalWidth + :PetalLength if :PetalLength > 1.3"
d"bysort :Species (:SepalLength) : egen :x = mean(:PetalWidth) if :SepalWidth < 3.4"
@jmboehm
Copy link
Owner

jmboehm commented Oct 7, 2021

Agreed.

@korenmiklos
Copy link

I think it is possible to override all binary operators with their elementwise counterparts. There must be a macro for that.

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

3 participants