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

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