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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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