Multiple "estimate" statements in PROC MIXED? #526
-
Hi there! first of all, this is my first post here. Wanted to thank the SASpy community for developing this awesome tool! Secondly, I'm a regular Python user/developer but am very new to SAS (hence SASpy has been incredibly useful to me). Now... I've been running some basic "PROC MIXED" procedures, such as this one (obtained from this blog):
I can run this procedure without problems with My question is: is there any currently supported way to submit multiple If not implemented, any idea how difficult would it be to modify the estimate argument in Thanks and best! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Hey, I can look into this and see. The proc generation code is the only part of SASPy I didn't write myself, so I'll need to dig through it to see if there is any support for this. I don't know off hand. Though not the right answer, I suspect that if you coded the following, it would actually work. Of course, the right way would be something like that statement parameter supporting a list, since it can be specified more than once in the proc, so you could provide a list of the strings for each statement instead of only one. But again, I'll have to try to dig through that code to see if anything like that was provided for. Bit of a hack that could work, since it's just simple substitution to build the SAS syntax.
Tom |
Beta Was this translation helpful? Give feedback.
-
Well, I can't find any indication in the code that's generating the procs that it supports statements that can be specified more than once. I see that when processing a statement that the value provided can be a list, but all that does is concatenate all the values together; not issue this statement for each value of the list. So, it allows you to specify
which both just produce That's a shame, because now list can't be used to support multiple of the same statement, and you can't just provide multiple of those statements (I tried that), because that's a Python syntax error since the method signature can't have multiple of the same keywords; that's where a list would make sense meaning multiple of these statements, one with each value in the list. Thus I don't believe support for multiple of the same statement was ever thought about in how this is generating the proc's. As dumb as the workaround is, up above that I showed, it might be the only way to get this to work for now. |
Beta Was this translation helpful? Give feedback.
-
Hey @tomweber-sas , thanks for your detailed answer. I tried your suggestion:
and it works well. Regarding the list of strings. Perhaps we could just add code to concatenate the argument (list of strings) in the right way so it can be rendered as proper SAS code. Still hackish but would be an easy fix, I think. This way the user could just input a list of statements without worrying about the proper format (I would not have guessed that I had to omit the first "estimate" in the concatenated string above). I could set aside some time and make a draft PR for this change. |
Beta Was this translation helpful? Give feedback.
-
Yes, that's what I was thinking to begin with, and may still be doable. It's just that list is used with other statements and means something different. There is enough special case code in all of this proc generation code for doing special things, due to the inconsistency of the syntax for every different proc. So, I could just add a check for this (do all the procs that support Estimate, allow it to be specified more than once?) and do it the correct way for Estimate. What other statements are allowed more than once? Our doc doesn't address this and I sure don't know. Guess I can just start with this case and work up others as they come in. What I was expecting would be:
I can code that up and let you try it out; push it to main for you to get. |
Beta Was this translation helpful? Give feedback.
-
Ok, so I've coded this up and for the following call, the generated code is below it. Note that I used a list for both Class and Estimate, but Class just concatenates the values w/in one statement (like it already did), while estimate builds a statement for each value in the list (like you need).
I've pushed this to main. Can you get it from there to validate it on your side? I'll need to figure out how to update the doc for this next. |
Beta Was this translation helpful? Give feedback.
-
Awesome, I tried it and this change does the job. Thanks! |
Beta Was this translation helpful? Give feedback.
Ok, so I've coded this up and for the following call, the generated code is below it. Note that I used a list for both Class and Estimate, but Class just concatenates the values w/in one statement (like it already did), while estimate builds a statement for each value in the list (like you need).