Help using Base SAS procedures

help, keep getting an error

Reply
New Contributor
Posts: 3

help, keep getting an error

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.
Frequent Contributor
Posts: 82

Re: help, keep getting an error

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? )
New Contributor
Posts: 3

Re: help, keep getting an error

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?
Super Contributor
Super Contributor
Posts: 365

Re: help, keep getting an error

Hello Mroos,

Please provide us with a small example of temp.

Sincerely,
SPR
Trusted Advisor
Posts: 2,113

Re: help, keep getting an error

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.
Contributor
Posts: 57

Re: help, keep getting an error

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.
New Contributor
Posts: 3

Re: help, keep getting an error

It was indeed a type error or that te order was wrong. It works now.
All thanks for the help.
New Contributor
Posts: 3

Re: help, keep getting an error

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

Super User
Posts: 17,750

Re: help, keep getting an error

@Meng_Xu Please post your question as a new thread. This one is more than 5 years old. Please include your code and log.
Ask a Question
Discussion stats
  • 8 replies
  • 910 views
  • 0 likes
  • 7 in conversation