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

Will greshape support strL variabes in the future? #91

Open
fredericky123 opened this issue Jun 1, 2023 · 4 comments
Open

Will greshape support strL variabes in the future? #91

fredericky123 opened this issue Jun 1, 2023 · 4 comments
Labels

Comments

@fredericky123
Copy link

Will greshape support strL variabes in the future?
Thanks a ton!

@mcaceresb
Copy link
Owner

mcaceresb commented Jun 1, 2023

@fredericky123 The current limitation of the Stata plugin API is that I can read strL variables in version 14.1 and later, but I cannot write strL variables at all, so I cannot support it.

You can try to coalesce strL variables into fixed length if that's feasible. You can also try to encode the strL variable and merge it back later (I believe gegen shoud be able to do that correctly; if you're on 16+ then you can use frames and that might not be so slow, but I haven't benchmarked it).

@fredericky123
Copy link
Author

Thanks a ton! @mcaceresb I see, strL variables can be read while not written. Just a thought, if greshape can be integrated with frames, that will be great since you said it might not be slow.

@mcaceresb
Copy link
Owner

mcaceresb commented Jun 1, 2023

@fredericky123 You can code it up as needed. I'm not sure what the general use case is, but encoding, copying the unique levels to a frame, reshaping, then merge (frlink/frget I think are the commands?) on the encoded variable. Something like this maybe?

gegen id = group(strLvar)
frame put id strLvar, into(tmp)
frame tmp: gduplicates drop
greshape ..., by(id ...) ...
frlink m:1 id , frame(tmp)
frget strLvar, from(tmp)

I don't know that I'd add it as a generic option (certainly not in the near future). There's also no way to interact with frames from the plugin, so the code I'd write would just be generic helper code like the pseudo-code snippet above.

@fredericky123
Copy link
Author

I see. Thanks a ton!

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