Help using Base SAS procedures

ERROR

Reply
Occasional Contributor SP2
Occasional Contributor
Posts: 8

ERROR

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.
Super Contributor
Posts: 319

Re: ERROR

Hi SP2,

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

Regards,
Milton
Trusted Advisor
Posts: 2,113

Re: ERROR

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
Ask a Question
Discussion stats
  • 2 replies
  • 141 views
  • 0 likes
  • 3 in conversation