1

I need to submit R statements in SAS. To do that, the SAS documentation recommand to enable the RLANG option (which I did) and then use the submit statement as follows :

submit / R;

(more details are available here, I use the exact example code.)

My issue is that the submit statement is not recognized : it appears in red in the editor and if I try to run the code anyway, I get the following error :

ERROR 180-322: Statement is not valid or it is used out of proper order.

I have the same issue if I try to use submit in another context. Any ideas how to fix this ?

Joe
  • 62,789
  • 6
  • 49
  • 67
Vincent
  • 955
  • 2
  • 15
  • 32

1 Answers1

2

The submit statement is a feature of the SAS/IML language, so it must be submitted during a SAS/IML code block.

proc iml;
 submit / R;
    x <- 5
    x

  endsubmit;
quit;

Further, you must have the RLANG system option set (which may be controlled by you or your administrator) at system startup.

For more information see the SAS documentation.

In addition, you need to have SAS/IML version 9.22 to use R. This comes with some installations of SAS 9.2 TS3M2, but having that release is not a guarantee of having the functionality available. Per this question on SAS Communities, Rick Wicklin suggests testing with this code:

proc iml;
c = cuprod(1:5);

If that does not work, then you do not have SAS/IML 9.22 and thus cannot use submit to R.

Joe
  • 62,789
  • 6
  • 49
  • 67
  • The RLANG option has already been enabled and I use the exact code provided in the SAS documentation (the link you posted is the same that I provided), which is indeed in an IML block. However, submit is not considered properly used. – Vincent May 05 '14 at 19:27
  • Submit the code in my code block, omitting the ..., in a fresh session. If you do that and get the same error, then I don't know. I did the above and it worked as expected. Your particular error is a bit odd, as it more suggests you have an open clause or something from before the submit statement (a missing `;` or something?). – Joe May 05 '14 at 20:05
  • I'm sorry, what should I omit ? I tried to run your code in a fresh session but `submit` is not recognized. I tried to remove the ";" after `proc iml` and the error turns into warning but r statements are still not available. – Vincent May 06 '14 at 07:19
  • What version of SAS are you running? I think maybe you are on an older version. – Joe May 06 '14 at 13:34
  • It's the 9.2 version. Is it that old ? But I agree that has to be something like that... EDIT : The doc is for SAS 9.22 so I guess this is not the issue... – Vincent May 06 '14 at 13:55
  • Actually, 9.22 is not necessarily the same as 9.2. What service version are you on (9.2 TS2M3 in my case, for example)? (9.2 does _not_ have submit to R; 9.22 was the first version this existed in.) – Joe May 06 '14 at 14:08
  • 9.2 TS2M3 too. As I was able to properly set `RLANG`, I assumed it was ok with this version... Isn't it ? – Vincent May 06 '14 at 14:21
  • I suppose. I don't understand your error then; it either implies you missed a semicolon somewhere or don't have `submit` available for some reason (like IML isn't installed properly). You might also have a problem with the `R` installation (like `path` problems?), but I think that would be a different error. I'm stumped. – Joe May 06 '14 at 14:22
  • Well I don't understand either... Seems like a stupid error but kind of beyond understanding. Thank you for your help anyway :) – Vincent May 06 '14 at 14:26
  • 1
    https://communities.sas.com/message/143243 suggests you might actually not have the right version. Try to run the test code Rick suggests (He's the SAS corporate guy who supports IML, so he probably knows what he's talking about.) – Joe May 06 '14 at 14:29
  • Bingo ! Quite weird that `RLANG` option is available but not `submit` isn't it ? Anyway, question answered. Thank you Joe ! – Vincent May 06 '14 at 14:36
  • Although I am a programmer that works at SAS, I like to think that I am not a "corporate guy." :-) Glad the problem got resolved. Nice work, Joe. – Rick May 07 '14 at 10:40
  • Haha, fair enough @rick. – Joe May 07 '14 at 11:27