-2

This question arises from two others I had regarding sending a batch job and also wraping that respective script in a macro for further loops (see here:

My code works as follows:

[1] I define some macro variables
[2] I create a data step view
[3] My data step uses the previous data step view to make some calculation
[4] Export the results

The first time: when I run 1+2, and then run [3]+[4]. The code works. I need to do this once and then I can run 1+2+[3]+[4] (the entire script) altogether. However, if I don't do this "split" run my code gives me the following error message:

116        data xtemp2;
117             set _v_&tables;
117             set _v_&tables;
                 ___
                 180
ERROR 180-322: Statement is not valid or it is used out of proper order.

118             by symbol date time;
                 __
                 180

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

119             format itime rtime time12.;
.
.
.

and so on, every line afterwards shows the same error. Please note that there are two times line 117, however my code has it only once.

I tried to put a sleep function in between the data steps, but the problem is the same.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
eternity1
  • 651
  • 2
  • 15
  • 31
  • You can sometimes get hard to explain errors she the macro variables are quoted in atypical ways. Try wrapping the macro variable resolution as %unquote(&tables). Use options mprint when troubleshooting. If 'tables' is a list of tables then the set statement is improper with respect for the generated statement. – Richard Mar 03 '18 at 22:29
  • Dear Richard, thank you very much. I have not set quotation marks around the variable, i.e. %let tables = cq_1998. – eternity1 Mar 03 '18 at 23:36
  • Does your code actually have two set statements, one right after the other? Or is the log just showing the same line twice. The normal reason that a SET statement is not valid is because the DATA statement did not run. You probably have a missing semi-colon higher up in the program. Add an extra 'run;` statement before the data step to help you debug. – Tom Mar 04 '18 at 00:56
  • It's not *really* possible to tell what's happening. You'd have to include more about your code (i.e., all of it). – Joe Mar 04 '18 at 06:21
  • Dear all, Richard has found the solution. I added extra "run;" statements before each of the data steps and now the code (run as a whole), the code wrapped in a macro as well as the batch job works! Thank you very much! – eternity1 Mar 04 '18 at 14:17

1 Answers1

1

As @Joe points out, there wasn't enough information here. However, judging by your answer to your previous question, the issue seems to be here:

73          '9:30:00't and '16:00:00't) and     mode = 12 and            EX =
73       ! 'N';           run;   *Screen data to find the trade before a set
73       ! time interval   data xtemp2;       set _v_&tables;       by symbol
                                           ___
                                           180
 73       ! date time;       format itime rtime time12.;       if
 ERROR 180-322: Statement is not valid or it is used out of proper order.

Your 'Screen data to find...' comment is not terminated with a semicolon, and so the data xtemp; statement becomes the end of the comment. Hence there is no data statement preceding the set statement.

Did you run this comment when you ran it 'step by step'?

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
  • Thanks Allan, the solution is as suggested by Richard: Adding extra "run;" before each data step and all of the sudden it works! – eternity1 Mar 04 '18 at 14:18