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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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.

View solution in original post

10 REPLIES 10
Reeza
Super User

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;

 


 

HB
Barite | Level 11 HB
Barite | Level 11

" 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?

bzimmermann
Calcite | Level 5

Here is the piece of the log

 

 

 

HB
Barite | Level 11 HB
Barite | Level 11

I don't open strange files from people I don't know. 

 

Just post text or code. 

bzimmermann
Calcite | Level 5
NOTE: Invalid argument to function INPUT at line 203 column 150. ERROR: Array subscript out of range at line 203 column 138. first_rec1=0 first_rec2=1 first_rec3=0 first_rec4=0 first_rec5=0 Terminate=N abort_flag=N abort_count=0 start_Quarter=1Q2017 start_date=01/01/2017 end_Quarter=4Q2017 end_date=12/31/2017 H_NUMB_COMP_RANGE= H_NUMB_COMP= H_RESP_RATE_P= H_COMP_1_SN_P= H_COMP_1_U_P= H_COMP_1_A_P= H_COMP_1_LIN= H_COMP_1_STAR= H_COMP_2_SN_P= H_COMP_2_U_P= H_COMP_2_A_P= H_COMP_2_LIN= H_COMP_2_STAR= H_COMP_3_SN_P= H_COMP_3_U_P= H_COMP_3_A_P= H_COMP_3_LIN= H_COMP_3_STAR= H_COMP_4_SN_P= H_COMP_4_U_P= H_COMP_4_A_P= H_COMP_4_LIN= H_COMP_4_STAR= H_COMP_5_SN_P= H_COMP_5_U_P= H_COMP_5_A_P= H_COMP_5_LIN= H_COMP_5_STAR= H_CLEAN_HSP_SN_P= H_CLEAN_HSP_U_P= H_CLEAN_HSP_A_P= H_CLEAN_HSP_LIN= H_CLEAN_HSP_STAR= H_QUIET_HSP_SN_P= H_QUIET_HSP_U_P= H_QUIET_HSP_A_P= H_QUIET_HSP_LIN= H_QUIET_HSP_STAR= H_COMP_6_Y_P= H_COMP_6_N_P= H_COMP_6_LIN= H_COMP_6_STAR= H_HSP_RATING_0_6= H_HSP_RATING_7_8= H_HSP_RATING_9_10= H_HSP_RATING_LIN= H_HSP_RATING_STAR= H_RECMND_DN= H_RECMND_PY= H_RECMND_DY= H_RECMND_LIN= H_RECMND_STAR= H_COMP_7_SD_P= H_COMP_7_A_P= H_COMP_7_SA_P= H_COMP_7_LIN= H_COMP_7_STAR= H_STAR_RATING= H_NUMB_COMP_F= M_ID_01=Composite 1 M_ID_02=Composite 2 M_ID_03=Composite 3 M_ID_04=Composite 4 M_ID_05=Composite 5 M_ID_06=Composite 6 M_ID_07=Composite 7 M_ID_08=Q8 M_ID_09=Q9 M_ID_10=Q 21 M_ID_11=Q 22 M_ID_12=Star Rating M_ID_desc_01=Communication with nurses M_ID_desc_02=Communication with doctors M_ID_desc_03=Responsiveness of hospital staff M_ID_desc_04=Pain management M_ID_desc_05=Communication about medicines M_ID_desc_06=Discharge information M_ID_desc_07=Care Transition M_ID_desc_08=Cleanliness of hospital environment M_ID_desc_09=Quietness of hospital environment M_ID_desc_10=Overall rating of hospital M_ID_desc_11=Willingness to recommend this hospital M_ID_desc_12=HCAHPS Summary Star Rating foot_c= a=1 b=0 eof=0 c=0 planname=01014F months_data=12 surveys=1134 eligibles=4672 ineligibles=25 completes=325 state_code=AL nur_bout_avg=7 nur_mid_avg=24 nur_tout_avg=69 nur_lout_avg=87 doc_bout_avg=4 doc_mid_avg=16 doc_tout_avg=80 doc_lout_avg=92 res_bout_avg=13 res_mid_avg=27 res_tout_avg=60 res_lout_avg=81 pai_bout_avg=17 pai_mid_avg=35 pai_tout_avg=48 pai_lout_avg=76 com_bout_avg=20 com_mid_avg=19 com_tout_avg=61 com_lout_avg=76 dis_bout_avg=21 dis_tout_avg=79 dis_lout_avg=79 cle_bout_avg=14 cle_mid_avg=26 cle_tout_avg=60 cle_lout_avg=81 qui_bout_avg=9 qui_mid_avg=32 qui_tout_avg=59 qui_lout_avg=82 ovr_bout_avg=9 ovr_mid_avg=27 ovr_tout_avg=64 ovr_lout_avg=87 rec_bout_avg=8 rec_mid_avg=26 rec_tout_avg=66 rec_lout_avg=86 ctm_bout_avg=5 ctm_mid_avg=47 ctm_tout_avg=48 ctm_lout_avg=81 nur_star=1 doc_star=3 res_star=2 pai_star=1 com_star=3 cle_star=1 qui_star=3 dis_star=1 ovr_star=3 rec_star=3 ctm_star=3 env_star=2 global_star=3 summary_star=2 fmtname= label= i=. foot_10=. foot_15=. foot_6=. foot_3a=. foot_3b=. foot_3=. foot_5a=. foot_5c=. foot_DR=. foot_5=. foot_1a=. foot_1b=. foot_1=. foot_11a=. foot_11b=. foot_HW=. foot_RR=. foot_1c=. foot_11z=. resp_perc=. SEQN=. PROVIDER_ID= H_FOOTNOTE= S_FOOTNOTE= err_count=0 no_avg=. foot_5b= j=. k=. x= Blank= Resp_rate= aa= bb= cc= dd= ee= _ERROR_=1 _N_=78
Reeza
Super User

You have two errors:

 
NOTE: Invalid argument to function INPUT at line 203 column 150.
ERROR: Array subscript out of range at line 203 column 138. 
 
What is the code from line 203 IN YOUR LOG?
 
 
bzimmermann
Calcite | Level 5
The weird thing it's just a let statement 202 %let mac_path = &Root.SAS_Code\Macro_lib\base\; 203 %let Reports = &Root.Data_From_Unix_for_Reports\&year._&qtr_no.\; 204 %let Raw = &Root.Quarterly\1_Download\&year._&qtr_no.\Raw_data; 205 %let Srce = &Root.Quarterly\1_Download\&year._&qtr_no.\Source;
Reeza
Super User

Then it's probably above those lines, the error isn't always exactly at the line indicated, but where it causes issues.

bzimmermann
Calcite | Level 5

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?

Tom
Super User Tom
Super User

@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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 1558 views
  • 0 likes
  • 4 in conversation