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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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