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
I just notice the wrong spelling of "fisrt". Sorry about that
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.
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
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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: