BookmarkSubscribeRSS Feed
mroos
Calcite | Level 5
For my research i need to get the yearly median of the bid- ask spread. I wrote a syntax but on some point of the syntax I keep getting an error. Can somebody help me with this by telling what is wrong and how to correct it. The error happens with the last line of the syntax shown below.

The errors that are shown are:
ERROR: File WORK.TEMP.DATA does not exist.
ERROR 180-322: Statement is not valid or it is used out of proper order.

The syntax is:
/*sort data ask*/
PROC IMPORT OUT= WORK.Temp1 DATAFILE= "C:\Users\Marcel\Documents\school\Master\thesis\Data\modified\bid ask spread\roos1.xls"
DBMS=EXCEL REPLACE; SHEET="'S1X(PA)$'"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; run;

proc transpose data=temp1 out=Temp2 (rename=(col1=Ask) drop= _LABEL_) name=ISIN;
var UKB16TW23_PA__E UK5884823_PA__E UK4264512_PA__E UKB23PWM1_PA__E UK5824391_PA__E
; by Date notsorted; run;
data ask (rename=(ask_n=ask)); set temp2;
ask_n=ask;
sedol=substr(isin,3,7); drop isin ask;
run;


/*sort data bid*/
PROC IMPORT OUT= WORK.Temp1 DATAFILE= "C:\Users\Marcel\Documents\school\Master\thesis\Data\modified\bid ask spread\roos1.xls"
DBMS=EXCEL REPLACE; SHEET="'S1X(PB)$'"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; run;
proc transpose data=temp1 out=Temp2 (rename=(col1=Bid) drop= _LABEL_) name=ISIN;
var UKB16TW23_PB__E UK5884823_PB__E UK4264512_PB__E UKB23PWM1_PB__E UK5824391_PB__E
; by Date notsorted; run;
data bid (rename=(bid_n=bid)); set temp2;
bid_n=bid;
sedol=substr(isin,3,7); drop isin bid;
run;

proc sql; create table BAS as select
a.*, b.bid, (a.ask-b.bid)*2/(a.ask+b.bid) as BAS
from ask as a inner join bid as b
on a.sedol=b.sedol and a.date=b.date
order by a.sedol, a.date;quit;

data temp1; set temp; year=year(date);

With this line I keep getting the error.
8 REPLIES 8
ieva
Pyrite | Level 9
This data set temp isn't mentioned anywhere before in your code, it is not created. Maybe it is just misspelling and you wanted to reference some other data set in this step:
data temp1; set temp; year=year(date);
(from which data set you want to create that new one? )
mroos
Calcite | Level 5
I indeed refered to the wrong data set. I corrected for this and now the first error is solved. But I still get the second error:

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

Does anybody what this error exactly means and how to solve this?
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Mroos,

Please provide us with a small example of temp.

Sincerely,
SPR
Doc_Duke
Rhodochrosite | Level 12
You need to show the log, so we can see which statement it is complaining about. Most of the time, that means there is a typo somewhere.
Sandhya
Fluorite | Level 6
Dear Mroos,

Run each dataset or procedure one by one. When you do this, you exactly know which module is failing. Narrowing down process simplifies error detection.

Post the module which has issues.

Regards,
Sandhya.
mroos
Calcite | Level 5
It was indeed a type error or that te order was wrong. It works now.
All thanks for the help.
Meng_Xu
Fluorite | Level 6

Hi Mroos,

 

How did you solve the error "STATEMENT IS NOT VALID OR IT IS USED OUT OF PROPER ORDER "?

 

I am stuck in this error, and have no idea how to solve this error. The error points to some of my options like MIXED=, GUESSINGROWS= ...

 

Thank you

Reeza
Super User
@Meng_Xu Please post your question as a new thread. This one is more than 5 years old. Please include your code and log.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 3173 views
  • 0 likes
  • 7 in conversation