Hi All thanks for your help with this. I did not originally create this program, but changes have been made to the incoming data that are causing this array to error out. I've tried about everything that I can think which means it's probably the easiest solution. The planname used to be numeric, but it is now alphanumeric, which is causing the error. Is there a way to use the alphanumeric planname?. This isn't the entire code just a small portion of it. Thanks again for your help.
data set1 set2;
array old_hsp_id {999999} $ 1 _temporary_ (999999*'N');
set combine (in=a)
incomingset_1(in=b rename=(start=planname)
where=(put(left(trim(planname)),$unq2_1.) = 'N' and
put(left(trim(planname)),$opn_1. ) = 'Y'))
incomingset_2(in=c rename=(start=planname)
where=(put(left(trim(planname)),$opnhspva. ) = 'Y')) end=eof;
* Check for duplicates ;
if (old_hsp_id (input(left(trim(planname)),6.)) = 'N') then old_hsp_id (input(left(trim(planname)),6.)) = 'Y';
else do;
error 'Hospital id is duplicated';
put _all_;
Terminate = 'Y';
end;
run;
@bzimmermann wrote:
The array is being used to identify duplicates within the planname field. The planname field used to be all numerical but it is now alpha-numeric which appears to be causing the problem. I was hoping to make the existing logic work rather than rewriting the process.
Does that give you the additional information you need?
Looks like your old code was making a giant temporary array to check for duplicates.
You probably will want to switch to using a HASH instead.
Or just sort the data and check for duplicates that way.
Can you post the error and include one line of the data from the log with it?
@bzimmermann wrote:
Hi All thanks for your help with this. I did not originally create this program, but changes have been made to the incoming data that are causing this array to error out. I've tried about everything that I can think which means it's probably the easiest solution. The planname used to be numeric, but it is now alphanumeric, which is causing the error. Is there a way to use the alphanumeric planname?. This isn't the entire code just a small portion of it. Thanks again for your help.
data set1 set2;
array old_hsp_id {999999} $ 1 _temporary_ (999999*'N');
set combine (in=a)
incomingset_1(in=b rename=(start=planname)
where=(put(left(trim(planname)),$unq2_1.) = 'N' and
put(left(trim(planname)),$opn_1. ) = 'Y'))
incomingset_2(in=c rename=(start=planname)
where=(put(left(trim(planname)),$opnhspva. ) = 'Y')) end=eof;
* Check for duplicates ;
if (old_hsp_id (input(left(trim(planname)),6.)) = 'N') then old_hsp_id (input(left(trim(planname)),6.)) = 'Y';
else do;
error 'Hospital id is duplicated';
put _all_;
Terminate = 'Y';
end;
run;
" The planname used to be numeric, but it is now alphanumeric, which is causing the error. "
What error is that?
If you had a field you were using as a unique identifier it should have been character to begin with- you aren't going to add or subtract it, it isn't numeric even if it was all numbers.
Maybe you could explain more about what the problem is?
Here is the piece of the log
I don't open strange files from people I don't know.
Just post text or code.
You have two errors:
Then it's probably above those lines, the error isn't always exactly at the line indicated, but where it causes issues.
The array is being used to identify duplicates within the planname field. The planname field used to be all numerical but it is now alpha-numeric which appears to be causing the problem. I was hoping to make the existing logic work rather than rewriting the process.
Does that give you the additional information you need?
@bzimmermann wrote:
The array is being used to identify duplicates within the planname field. The planname field used to be all numerical but it is now alpha-numeric which appears to be causing the problem. I was hoping to make the existing logic work rather than rewriting the process.
Does that give you the additional information you need?
Looks like your old code was making a giant temporary array to check for duplicates.
You probably will want to switch to using a HASH instead.
Or just sort the data and check for duplicates that way.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.