error msg:- Statement is not valid or it is used out of proper order.

Reply
N/A
Posts: 1

error msg:- Statement is not valid or it is used out of proper order.

I am trying to read data using datalines and it keeps giving me the msg:-  Statement is not valid or it is used out of proper order. it has also highlighted the first word in my data - Jack- in red. really not sure why.

data midterm.student;

infile datalines dsd;

input name : $12. ID $ weight height gender $ GPA;

datalines;

Jack 12-3456 192 72 M 3.3 Gill 23-4567 131 69 F 3.5 Jay 34-5678 . 70 M 2.9 Elizabeth 45-6789 115 68 F . Joanne 56-7890 121 70 F 3.8 Peggy 67-8901 135 67 F 3.6 Wahsington 78-9012 213 73 M 3.8 Jim 89-0123 200 70 M 3.4;

run;

Trusted Advisor
Posts: 1,137

Re: error msg:- Statement is not valid or it is used out of proper order.

What i observed after, executing the code above is that, you have placed the semicolon after the end of the last raw data (Jim 89-0123 200 70 M 3.4Smiley Wink which is not correct, sas is considering this as a statement which is not valid and throwing a syntax error. in order to avoid it you have to place the semi colon after the last record. Also there are missing values in the raw data, so it is a good option to use missover instead of dsd. dsd can be used if the data is separated by comma.

Please try the below code

data student;

infile datalines missover ;

input name : $12. ID $ weight height gender$ GPA;

datalines;

Jack 12-3456 192 72 M 3.3

Gill 23-4567 131 69 F 3.5

Jay 34-5678 . 70 M 2.9

Elizabeth 45-6789 115 68 F .

Joanne 56-7890 121 70 F 3.8

Peggy 67-8901 135 67 F 3.6

Wahsington 78-9012 213 73 M 3.8

Jim 89-0123 200 70 M 3.4

;

run;

Thanks,

jagadish

Thanks,
Jag
Super User
Super User
Posts: 7,060

Re: error msg:- Statement is not valid or it is used out of proper order.

Posted in reply to Jagadishkatam

Use TRUNCOVER instead of MISSOVER to avoid headache of skipping truncated values.

PROC Star
Posts: 7,480

Re: error msg:- Statement is not valid or it is used out of proper order.

A couple of problems.  First, you only have one dataline and it ends with a semi-colon.  Move that semi-colon down to have its own line.

Second, since all of your data are on the same line, end the input statement with a double @ option.  i.e.,

data midterm.student;

infile datalines;

input name : $12. ID $ weight height gender $ GPA @@;

datalines;

Jack 12-3456 192 72 M 3.3 Gill 23-4567 131 69 F 3.5 Jay 34-5678 . 70 M 2.9 Elizabeth 45-6789 115 68 F . Joanne 56-7890 121 70 F 3.8 Peggy 67-8901 135 67 F 3.6 Wahsington 78-9012 213 73 M 3.8 Jim 89-0123 200 70 M 3.4

;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 529 views
  • 0 likes
  • 4 in conversation