BookmarkSubscribeRSS Feed
SP2
Calcite | Level 5 SP2
Calcite | Level 5
I have the following code,
PROC IMPORT OUT= WORK.Data
DATAFILE= "/home/rtp00//DataSets/Data.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
PROC IMPORT OUT= WORK.Pc_factors
DATAFILE= "/home/rtp00/DataSets/PC factors.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
PROC IMPORT OUT= WORK.Class_base_rates
DATAFILE= "/home/rtp00//DataSets/ClassBaseRates.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;

PROC SQL;
CREATE table Work.Impact as
SELECT Data.Product,Data.Seg,Data.Company,Data.Building,Class_base_rates.Class

From Data
LEFT OUTER JOIN Pc_factors
ON Data.ProtCd=Pc_factors.ProtClass
And Data.Seg=Pc_factors.Segments

LEFT OUTER JOIN Class_base_rates
ON Data.Product=Class_base_rates.Product
AND Data.Class=Class_base_rates.Class
;
Quit;
This is showing an error . It says"ERROR;Expression using equals (=) has components that are of different data types" I can not spot any error.
My second question is , in the above query, all the datasets are importing from csv files. How can I format the variables? for example the variable Class is to be numeric?
Thanks.
2 REPLIES 2
milts
Pyrite | Level 9
Hi SP2,

For your second question:
Try adding the MIXED=YES option in your PROC IMPORT. Hope it works.

Regards,
Milton
Doc_Duke
Rhodochrosite | Level 12
If you do a PROC CONTENTS between the IMPORT and the SQL, you will see the fields that are of mis-matched types.

It is fairly common for IMPORT to guess the wrong data type on .csv files. The GUESSINGROWS statement can help it get it right.

Another possibility would be to use EGuide 4.2 to set up the data read. The code that it generates is much more robust than the basic SAS 9.2 IMPORT. You can then copy that code into your program.

Doc Muhlbaier
Duke

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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