BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
TennisKM3
Calcite | Level 5

Hi, I am currently studying for the SAS advanced programing exam. One of the practice questions has the following answer but when I try to run the code I get the below error. I tried changing the name of the hash object to something else but that didn't work. 

 

ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 558-185: Reference definedate is not a member of object c.

 

DATA examples

work.continent

ID CtName
91 North America
93 Europe

 

work.airports

ID City Code Aname Country
91 Anchorage, AK ANC Anchorage International Airport USA
93 Stockholm ARN Arlanda Sweden

 

CODE:

Data work.success work.fail;
drop rc;
length CtName $30;
If _N_=1 then do;
Call missing (CtName);
declare hash c(dataset:'work.continent');
c.definekey('ID');
c.definedate('CtName');
c.definedone();
end;
set work.airports;
rc=c.find();

if rc=0 then output work.sucess;

else output work.fail;

run;

 

Proc print data=work.sucess;

run;

 

Proc print data=work.fail;

run;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @TennisKM3,

 

Just two typos:

  1. The method's name is DEFINEDATA, not DEFINEDATE.
  2. The second "c" is missing in work.success in the OUTPUT statement and the PROC PRINT step.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @TennisKM3,

 

Just two typos:

  1. The method's name is DEFINEDATA, not DEFINEDATE.
  2. The second "c" is missing in work.success in the OUTPUT statement and the PROC PRINT step.
TennisKM3
Calcite | Level 5

Thanks! Spelling gets me every time. 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 200 views
  • 0 likes
  • 2 in conversation