BookmarkSubscribeRSS Feed
Macy
Calcite | Level 5

can anyone  help to look at below log, i do not know where is the problem.

 

PROC SQL;
CREATE TABLE GC.GermanCredit_Guanantor
AS
SELECT GermanCredit.Guarantor,GermanCredit.CO-APPLICANT
,(CASE
WHEN ( Guarantor =1 or CO-APPLICANT = 1) THEN 1
ELSE 0
END) AS Guarantor
FROM GC.GermanCredit;
QUIT;

 

64 FROM GC.GermanCredit;
ERROR: Column CO could not be found in the table/view identified with the correlation name GERMANCREDIT.
ERROR: The following columns were not found in the contributing tables: APPLICANT, CO.

屏幕快照 2016-11-27 上午7.57.34.png
9 REPLIES 9
Reeza
Super User

GermanCredit.CO-APPLICANT -> this is not a valid variable name. It's either an underscore or possibly GermanCredit.'CO-APPLICANT'n

 

Run a proc contents on the dataset and see what the variable name is. 

Macy
Calcite | Level 5

but in the data, it does show as CO-APPLICANT, see attached screen shot. 


屏幕快照 2016-11-27 上午8.11.31.png
Reeza
Super User

Then it's the second option I indicated with quotes. 

 

You need to reference it as a name literal. 

See details here

http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p18cdcs4v5wd2dn1q0x2...

Macy
Calcite | Level 5

i tried it, but it does not show what i want, it still shows as tow columns, not merge to be one column.

what i want it either column shows '1', then it shows results as '1, else'0', but as you can see it does not even merge to be one column. 


屏幕快照 2016-11-27 上午8.18.04.png
Reeza
Super User

Your CASE statement is incorrect, you can't have two variables with the same name in a data step. 

I'm surprised the log doesn't have any errors. 

 

Post your corrected code and log please. 

 

To correct your CASE add the alias for each variable and give it a new, unique name. 

 

 

Macy
Calcite | Level 5

i change the name to be APPLICANT, and tried to run the log again, but still it shows error. 


屏幕快照 2016-11-27 上午8.33.01.png
Reeza
Super User

What error? I don't see any error in your code or log. 

Macy
Calcite | Level 5

i got your point, i shall change it to be AS NewGuarantor, otherwise it is the same as the data variable, it works now, appreciate  your help!!

 

PROC SQL;
CREATE TABLE GC.GermanCredittApp
AS
SELECT GermanCreditt.Guarantor, GermanCreditt.APPLICANT
,(CASE
WHEN (Guarantor = 1 or APPLICANT = 1) THEN 1
ELSE 0
END) AS NewGuarantor
FROM GC.GermanCreditt;
QUIT;

Macy
Calcite | Level 5

i got your point, i shall change it to be AS NewGuarantor, otherwise it is the same as the data variable, it works now, appreciate  your help!!

 

PROC SQL;
CREATE TABLE GC.GermanCredittApp
AS
SELECT GermanCreditt.Guarantor, GermanCreditt.APPLICANT
,(CASE
WHEN (Guarantor = 1 or APPLICANT = 1) THEN 1
ELSE 0
END) AS NewGuarantor
FROM GC.GermanCreditt;
QUIT;


屏幕快照 2016-11-27 上午8.47.10.png屏幕快照 2016-11-27 上午8.47.19.png

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 4474 views
  • 0 likes
  • 2 in conversation