BookmarkSubscribeRSS Feed
mokleber
Calcite | Level 5

I am very new to SAS as I am learning it currently for a college course. I am getting this error, "ERROR: Expression using equals (=) has components that are of different data types.", with the following code;

libname mk "/home/u62148011/sasuser.v94";
run;

proc contents data= mk.aha;
run;

PROC SQL;
CREATE TABLE WORK.query AS
   SELECT PHAGMISS

   FROM mk.aha

   ORDER BY PHAGMISS= "5";
RUN;
QUIT;

 

I believe the error is occurring with the ORDER BY statement. Any advice or help you can give would be great.

2 REPLIES 2
ballardw
Super User

It would appear that your variable PHAGMISS is numeric.

Look at your Proc Contents output. Does it show NUM as Type for that variable? Num means numeric in Proc Contents type values.

 

Why do you have an = on the Order by anyway? Do you want the records where Phagmiss=5 to be at the end?

Kurt_Bremser
Super User
ORDER BY PHAGMISS= "5";

PHAGMISS seems to be numeric.

Your ORDER BY value is the result of a comparison, so the ORDER BY clause will put all the 5's at the end of the resulting dataset. Is this what you want?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 449 views
  • 0 likes
  • 3 in conversation