BookmarkSubscribeRSS Feed
qinghe
Calcite | Level 5

Hi there,

 

I have got the following error message:

 

"557: LINE and COLUMN cannot be determined.

NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.

ERROR 557-185: Variable fisrt is not an object.

ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

real time 0.00 seconds

user cpu time 0.00 seconds

system cpu time 0.00 seconds

memory 131.12k

OS Memory 14892.00k

Timestamp 01/14/2016 10:32:49 AM

 

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:

5, 10

ERROR: The %TO value of the %DO I loop is invalid.

ERROR: The macro HP3067 will stop executing."

 

The macro is as belw:

 

%macro HP3067(yr1, yr2, yr3);

data HP;

set hosp_proc&yr2 hosp_proc&yr3;

%sort(HP, Indig);

data HP;

set HP;

by indig;

if fisrt.indig then do;

%do i=1 %to 5, 10;

p&i=0;

%end;

total=0;

end;

total+1;

%do i=1 %to 5, 10;

if procedure_no=&i then p&i+1;

%end;

%do i=1 %to 5, 10;

pct&i=p&i/total* 100;

%end;

pt=100;

if last.indig then output;

run;

%mend;

 

Anyone can tell me what I did wrong? Thanks.

 

qinghe

4 REPLIES 4
qinghe
Calcite | Level 5

I just notice the wrong spelling of "fisrt". Sorry about that

Reeza
Super User

Does that fix your error?

 

I will mention that your code may be easier to understand and navigate via arrays rather than macro variables. I'm not sure they add value to your process, beyond the year definitions.

qinghe
Calcite | Level 5

Hi Reeza

 

This is not the only error. The macro %to does not accept 5, 10. For 10 I have to do it seperately. You are right, use array should be easier. Thanks.

 

Qinghe

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

There are few things incorrect in there.  The typo in first as picked up before.  Also you do not retain total so that wont work.  I am not sure about a lot of the syntax you have used either.  I would suggest that you post example test data (in the form of a datastep) and required output.  Also note that good code formatting really helps others to read your code - indetation, consitent casing - finishing blocks - not creating obfuscation macros (%sort, what does it do, how do I use it etc. versus proc sort which I know how to use).  I have tried tidying up the code below, and show the use of arrays, but without data I can't really compress any.

 

 

data hp;
  set hosp_proc2012 hosp_proc2013;
run;

proc sort data=hp;
  by indig;
run;

data hp;
  set hp; 
  by indig;
  retain total;
  array p{3} 8.;
  array pct{3} 8.;
  array tests{3} 8. (1,5,10);
  if first.indig then do;
    call missing(of p{*});
    total=0;
  end;
  total=total+1;
  do i=1 to 3;
    if procedure_no=tests{i} then p{i}=p{i}+1;
  end;
  do i=1 to 3;
    pct{i}=(p{i} / total) * 100;
  end;
  if last.indig then output;
run;

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!

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
  • 4 replies
  • 1144 views
  • 0 likes
  • 3 in conversation