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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 282 views
  • 0 likes
  • 3 in conversation