BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Afor910327
Obsidian | Level 7

 

Does anyone see the error below? I do not see anything. 

 

proc sql;
9251
9252 create table trans1 as
9253
9254 select itmCode_id as itemCode_id label="itemCode_id", itmCode as itemCode
9254! label="itemCode", itmDescr label="itemDesc",
9255 period as ioYear, sum(val) as proVal label="proVal"
9256 from sqltrn.dataView
9257 where period = 2012
9258 and datasetName = 'annual17'
9259 and schemaName = 'NAICS12'
9260 and valType in ('DOM','IMP','CTX')
9261 group by itmCode_id, itmCode, itmDescr, period
9262 order by itmCode_id
9263 ;
ERROR: Expression using equals (=) has components that are of different data types.
9264 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Maxim 3: Know Your Data.

Run a proc contents on dataset sqltrn.dataView to determine the types of the variables used in your where condition.

My most suspected culprits:

  • period might actually be character
  • valtype could be coded as numeric, and have a custom format overlayed

Please let us know what proc contents has to say.

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@Afor910327 wrote:

 

Does anyone see the error below? I do not see anything. 

 

proc sql;
9251
9252 create table trans1 as
9253
9254 select itmCode_id as itemCode_id label="itemCode_id", itmCode as itemCode
9254! label="itemCode", itmDescr label="itemDesc",
9255 period as ioYear, sum(val) as proVal label="proVal"
9256 from sqltrn.dataView
9257 where period = 2012
9258 and datasetName = 'annual17'
9259 and schemaName = 'NAICS12'
9260 and valType in ('DOM','IMP','CTX')
9261 group by itmCode_id, itmCode, itmDescr, period
9262 order by itmCode_id
9263 ;
ERROR: Expression using equals (=) has components that are of different data types.
9264 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds


ERROR: Expression using equals (=) has components that are of different data types.

 

This indicates one of your variables is not the right type given the testing in the WHERE clause.

 

period = 2012 means the variable period must be numeric (is it?)

datasetName = 'annual17' means that datasetName must be character (is it?)

same for SchemaName and ValType

--
Paige Miller
Kurt_Bremser
Super User

Maxim 3: Know Your Data.

Run a proc contents on dataset sqltrn.dataView to determine the types of the variables used in your where condition.

My most suspected culprits:

  • period might actually be character
  • valtype could be coded as numeric, and have a custom format overlayed

Please let us know what proc contents has to say.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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