BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
CathyVI
Lapis Lazuli | Level 10

Hello,

I am getting this error with my code which is trying to create a wide format of my variables. Similar issue have been resolved online but I could not figure out the problem. Thanks in advance.

Here is the code and log:

/* STEP 5.2: TRANSFORM CARRIER LINE FILE */
data bcarline2016_2021_wide (drop=i line_1st_expns_dt line_last_expns_dt hcpcs_cd line_icd_dgns_cd line_num line_nch_pmt_amt prf_physn_npi tax_num);
	format  line_1st_expns_dt_1-line_1st_expns_dt_13 mmddyy10.
			line_last_expns_dt_1-line_last_expns_dt_13 mmddyy10.
			line_icd_dgns_cd1- line_icd_dgns_cd13 $5.
			hcpcs_cd1-hcpcs_cd13 $7.
			line_nch_pmt_amt1-line_nch_pmt_amt13 10.2  
			prf_physn_npi1-prf_physn_npi13 $12.    
			tax_num1-tax_num13 $10.;  
	set bcarline2016_2021;
	by bene_id clm_id line_num;
	retain 	line_1st_expns_dt_1-line_1st_expns_dt_13 
			line_last_expns_dt_1-line_last_expns_dt_13 
			line_icd_dgns_cd1-line_icd_dgns_cd13
			hcpcs_cd1-hcpcs_cd13 
			line_nch_pmt_amt1-line_nch_pmt_amt13   
			prf_physn_npi1-prf_physn_npi13    
			tax_num1-tax_num13;   

	array   xline_icd_dgns_cd(13) line_icd_dgns_cd1-line_icd_dgns_cd13;
	array	xline_1st_expns_dt_(13) line_1st_expns_dt_1-line_1st_expns_dt_13; 
	array	xline_last_expns_dt_(13) line_last_expns_dt_1-line_last_expns_dt_13; 
	array	xhcpcs_cd(13) hcpcs_cd1-hcpcs_cd13; 
	array	xline_nch_pmt_amt(13) line_nch_pmt_amt1-line_nch_pmt_amt13;   
	array	xprf_physn_npi(13) prf_physn_npi1-prf_physn_npi13;    
	array	xtax_num(13) tax_num1-tax_num13;   

	if first.clm_id then do;
		do i=1 to 13;
			xline_icd_dgns_cd(line_num)='';
			xline_1st_expns_dt_(line_num)=.; 
			xline_last_expns_dt_(line_num)=.; 
			xhcpcs_cd(line_num)=''; 
			xline_nch_pmt_amt(line_num)=.;  
			xprf_physn_npi(line_num)='';   
			xtax_num(line_num)='';  
		end;
	end;

	xline_icd_dgns_cd(line_num)=line_icd_dgns_cd;
	xline_1st_expns_dt_(line_num)=line_1st_expns_dt; 
	xline_last_expns_dt_(line_num)=line_last_expns_dt; 
	xhcpcs_cd(line_num)=hcpcs_cd; 
	xline_nch_pmt_amt(line_num)=line_nch_pmt_amt;   
	xprf_physn_npi(line_num)=prf_physn_npi;    
	xtax_num(line_num)=tax_num;   

	if last.clm_id then output;
run;

Log:

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         /* STEP 5.2: TRANSFORM CARRIER LINE FILE */
 74         data bcarline2016_2021_wide (drop=i line_1st_expns_dt line_last_expns_dt hcpcs_cd line_icd_dgns_cd line_num
 74       ! line_nch_pmt_amt prf_physn_npi tax_num);
 75         format  line_1st_expns_dt_1-line_1st_expns_dt_13 mmddyy10.
 76         line_last_expns_dt_1-line_last_expns_dt_13 mmddyy10.
 77         line_icd_dgns_cd1- line_icd_dgns_cd13 $5.
 78         hcpcs_cd1-hcpcs_cd13 $7.
 79         line_nch_pmt_amt1-line_nch_pmt_amt13 10.2
 80         prf_physn_npi1-prf_physn_npi13 $12.
 81         tax_num1-tax_num13 $10.;
 82         set bcarline2016_2021;
 83         by bene_id clm_id line_num;
 84         retain line_1st_expns_dt_1-line_1st_expns_dt_13
 85         line_last_expns_dt_1-line_last_expns_dt_13
 86         line_icd_dgns_cd1-line_icd_dgns_cd13
 87         hcpcs_cd1-hcpcs_cd13
 88         line_nch_pmt_amt1-line_nch_pmt_amt13
 89         prf_physn_npi1-prf_physn_npi13
 90         tax_num1-tax_num13;
 91         
 92         array   xline_icd_dgns_cd(13) line_icd_dgns_cd1-line_icd_dgns_cd13;
 93         arrayxline_1st_expns_dt_(13) line_1st_expns_dt_1-line_1st_expns_dt_13;
 94         arrayxline_last_expns_dt_(13) line_last_expns_dt_1-line_last_expns_dt_13;
 95         arrayxhcpcs_cd(13) hcpcs_cd1-hcpcs_cd13;
 96         arrayxline_nch_pmt_amt(13) line_nch_pmt_amt1-line_nch_pmt_amt13;
 97         arrayxprf_physn_npi(13) prf_physn_npi1-prf_physn_npi13;
 98         arrayxtax_num(13) tax_num1-tax_num13;
 99         
 100        if first.clm_id then do;
 101        do i=1 to 13;
 102        xline_icd_dgns_cd(line_num)='';
 103        xline_1st_expns_dt_(line_num)=.;
 104        xline_last_expns_dt_(line_num)=.;
 105        xhcpcs_cd(line_num)='';
 106        xline_nch_pmt_amt(line_num)=.;
 107        xprf_physn_npi(line_num)='';
 108        xtax_num(line_num)='';
 109        end;
 110        end;
 111        
 112        xline_icd_dgns_cd(line_num)=line_icd_dgns_cd;
 113        xline_1st_expns_dt_(line_num)=line_1st_expns_dt;
 114        xline_last_expns_dt_(line_num)=line_last_expns_dt;
 115        xhcpcs_cd(line_num)=hcpcs_cd;
 116        xline_nch_pmt_amt(line_num)=line_nch_pmt_amt;
 117        xprf_physn_npi(line_num)=prf_physn_npi;
 118        xtax_num(line_num)=tax_num;
 119        
 120        if last.clm_id then output;
 121        run;
 
 ERROR: Array subscript out of range at line 112 column 2.
 line_1st_expns_dt_1=04/15/2021 line_1st_expns_dt_2=04/15/2021 line_1st_expns_dt_3=04/15/2021 line_1st_expns_dt_4=04/15/2021
 line_1st_expns_dt_5=04/15/2021 line_1st_expns_dt_6=04/15/2021 line_1st_expns_dt_7=04/15/2021 line_1st_expns_dt_8=04/15/2021
 line_1st_expns_dt_9=04/15/2021 line_1st_expns_dt_10=04/15/2021 line_1st_expns_dt_11=04/15/2021 line_1st_expns_dt_12=04/15/2021
 line_1st_expns_dt_13=04/15/2021 line_last_expns_dt_1=04/15/2021 line_last_expns_dt_2=04/15/2021 line_last_expns_dt_3=04/15/2021
 line_last_expns_dt_4=04/15/2021 line_last_expns_dt_5=04/15/2021 line_last_expns_dt_6=04/15/2021 line_last_expns_dt_7=04/15/2021
 line_last_expns_dt_8=04/15/2021 line_last_expns_dt_9=04/15/2021 line_last_expns_dt_10=04/15/2021 line_last_expns_dt_11=04/15/2021
 line_last_expns_dt_12=04/15/2021 line_last_expns_dt_13=04/15/2021 line_icd_dgns_cd1=E782 line_icd_dgns_cd2=E782
 line_icd_dgns_cd3=E782 line_icd_dgns_cd4=E782 line_icd_dgns_cd5=E782 line_icd_dgns_cd6=E782 line_icd_dgns_cd7=E782
 line_icd_dgns_cd8=E782 line_icd_dgns_cd9=E782 line_icd_dgns_cd10=E782 line_icd_dgns_cd11=E782 line_icd_dgns_cd12=E782
 line_icd_dgns_cd13=E782 hcpcs_cd1=81161 hcpcs_cd2=81238 hcpcs_cd3=81411 hcpcs_cd4=81413 hcpcs_cd5=81414 hcpcs_cd6=81401
 hcpcs_cd7=81404 hcpcs_cd8=81404 hcpcs_cd9=81404 hcpcs_cd10=81404 hcpcs_cd11=81404 hcpcs_cd12=81405 hcpcs_cd13=81405
 line_nch_pmt_amt1=279.00 line_nch_pmt_amt2=600.00 line_nch_pmt_amt3=1350.19 line_nch_pmt_amt4=584.90 line_nch_pmt_amt5=584.90
 line_nch_pmt_amt6=137.00 line_nch_pmt_amt7=274.83 line_nch_pmt_amt8=274.83 line_nch_pmt_amt9=274.83 line_nch_pmt_amt10=274.83
 line_nch_pmt_amt11=274.83 line_nch_pmt_amt12=301.35 line_nch_pmt_amt13=301.35 prf_physn_npi1=1386023620 prf_physn_npi2=1386023620
 prf_physn_npi3=1386023620 prf_physn_npi4=1386023620 prf_physn_npi5=1386023620 prf_physn_npi6=1386023620 prf_physn_npi7=1386023620
 prf_physn_npi8=1386023620 prf_physn_npi9=1386023620 prf_physn_npi10=1386023620 prf_physn_npi11=1386023620 prf_physn_npi12=1386023620
 prf_physn_npi13=1386023620 tax_num1=472935323 tax_num2=472935323 tax_num3=472935323 tax_num4=472935323 tax_num5=472935323
 tax_num6=472935323 tax_num7=472935323 tax_num8=472935323 tax_num9=472935323 tax_num10=472935323 tax_num11=472935323
 tax_num12=472935323 tax_num13=472935323 BENE_ID=eeeeee119111E11 CLM_ID=eeeeJ9jJE9reaEa LINE_NUM=14 CLM_THRU_DT=15APR2021
 PRF_PHYSN_NPI=1386023620 TAX_NUM=472935323 LINE_1ST_EXPNS_DT=15APR2021 LINE_LAST_EXPNS_DT=15APR2021 HCPCS_CD=81406
 LINE_NCH_PMT_AMT=282.88 LINE_ICD_DGNS_CD=E782 Year=2021 Case=Lines FIRST.BENE_ID=0 LAST.BENE_ID=0 FIRST.CLM_ID=0 LAST.CLM_ID=0
 FIRST.LINE_NUM=1 LAST.LINE_NUM=1 i=. _ERROR_=1 _N_=5808
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: There were 5809 observations read from the data set WORK.BCARLINE2016_2021.
 WARNING: The data set WORK.BCARLINE2016_2021_WIDE may be incomplete.  When this step was stopped there were 3237 observations and 
          96 variables.
 WARNING: Data set WORK.BCARLINE2016_2021_WIDE was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 122        
 123        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 135        

  

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

This code I found in the book SAS® Programming with Medicare Administrative Data, and this was similar to the data am using except my data is from 2016-2021.

 

So to summarize, the code doesn't work, it doesn't make sense to us, and it is inefficient. I think you would be wise to simply start over and write your own code and work with a long data set.

--
Paige Miller

View solution in original post

12 REPLIES 12
PaigeMiller
Diamond | Level 26
 ERROR: Array subscript out of range at line 112 column 2.

What is line 112?

 

 112        xline_icd_dgns_cd(line_num)=line_icd_dgns_cd;

Based on this line, we need to know the value of the subscript line_num, and the log shows you the value of line_num=14

 

tax_num12=472935323 tax_num13=472935323 BENE_ID=eeeeee119111E11 CLM_ID=eeeeJ9jJE9reaEa LINE_NUM=14 CLM_THRU_DT=15APR2021

Your array xline_icd_dgns_cd is defined as having 13 elements. So it doesn't know what element 14 of the array is.

 

 

--
Paige Miller
CathyVI
Lapis Lazuli | Level 10

@PaigeMiller @ballardw @Kurt_Bremser  This code I found in the book SAS® Programming with Medicare Administrative Data, and this was similar to the data am using except my data is from 2016-2021.

With the code below, line_num max=50. Do I use 50 in the do statement?

proc sql;
select max(line_num)
from bcarline2016_2021;
quit;

I used the call missing in the code but I got an error/warning

/* STEP 5.2: TRANSFORM CARRIER LINE FILE */
data bcarline2016_2021_wide (drop=i line_1st_expns_dt line_last_expns_dt hcpcs_cd line_icd_dgns_cd line_num line_nch_pmt_amt prf_physn_npi tax_num);
	format  line_1st_expns_dt_1-line_1st_expns_dt_13 mmddyy10.
			line_last_expns_dt_1-line_last_expns_dt_13 mmddyy10.
			line_icd_dgns_cd1- line_icd_dgns_cd13 $5.
			hcpcs_cd1-hcpcs_cd13 $7.
			line_nch_pmt_amt1-line_nch_pmt_amt13 10.2  
			prf_physn_npi1-prf_physn_npi13 $12.    
			tax_num1-tax_num13 $10.;  
	set bcarline2016_2021;
	by bene_id clm_id line_num;
	retain 	line_1st_expns_dt_1-line_1st_expns_dt_13 
			line_last_expns_dt_1-line_last_expns_dt_13 
			line_icd_dgns_cd1-line_icd_dgns_cd13
			hcpcs_cd1-hcpcs_cd13 
			line_nch_pmt_amt1-line_nch_pmt_amt13   
			prf_physn_npi1-prf_physn_npi13    
			tax_num1-tax_num13;   

	array   xline_icd_dgns_cd(13) line_icd_dgns_cd1-line_icd_dgns_cd13;
	array	xline_1st_expns_dt_(13) line_1st_expns_dt_1-line_1st_expns_dt_13; 
	array	xline_last_expns_dt_(13) line_last_expns_dt_1-line_last_expns_dt_13; 
	array	xhcpcs_cd(13) hcpcs_cd1-hcpcs_cd13; 
	array	xline_nch_pmt_amt(13) line_nch_pmt_amt1-line_nch_pmt_amt13;   
	array	xprf_physn_npi(13) prf_physn_npi1-prf_physn_npi13;    
	array	xtax_num(13) tax_num1-tax_num13;   

	if first.clm_id then do;
 		do i=1 to 13; 	
		call missing(
         of xline_icd_dgns_cd(*)
		,of xline_1st_expns_dt_(*)
		,of xline_last_expns_dt_(*)
		,of xhcpcs_cd(*)
		,of xline_nch_pmt_amt(*)
		,of xprf_physn_npi(*) 
		,of xtax_num(*) 
            ); 
		end;
	end;

	xline_icd_dgns_cd(line_num)=line_icd_dgns_cd;
	xline_1st_expns_dt_(line_num)=line_1st_expns_dt; 
	xline_last_expns_dt_(line_num)=line_last_expns_dt; 
	xhcpcs_cd(line_num)=hcpcs_cd; 
	xline_nch_pmt_amt(line_num)=line_nch_pmt_amt;   
	xprf_physn_npi(line_num)=prf_physn_npi;    
	xtax_num(line_num)=tax_num;   

	if last.clm_id then output;
run;

Still got the same error in the log

ERROR: Array subscript out of range at line 122 column 2.
 line_1st_expns_dt_1=04/15/2021 line_1st_expns_dt_2=04/15/2021 line_1st_expns_dt_3=04/15/2021 line_1st_expns_dt_4=04/15/2021
 line_1st_expns_dt_5=04/15/2021 line_1st_expns_dt_6=04/15/2021 line_1st_expns_dt_7=04/15/2021 line_1st_expns_dt_8=04/15/2021
 line_1st_expns_dt_9=04/15/2021 line_1st_expns_dt_10=04/15/2021 line_1st_expns_dt_11=04/15/2021 line_1st_expns_dt_12=04/15/2021
 line_1st_expns_dt_13=04/15/2021 line_last_expns_dt_1=04/15/2021 line_last_expns_dt_2=04/15/2021 line_last_expns_dt_3=04/15/2021
 line_last_expns_dt_4=04/15/2021 line_last_expns_dt_5=04/15/2021 line_last_expns_dt_6=04/15/2021 line_last_expns_dt_7=04/15/2021
 line_last_expns_dt_8=04/15/2021 line_last_expns_dt_9=04/15/2021 line_last_expns_dt_10=04/15/2021 line_last_expns_dt_11=04/15/2021
 line_last_expns_dt_12=04/15/2021 line_last_expns_dt_13=04/15/2021 line_icd_dgns_cd1=E782 line_icd_dgns_cd2=E782
 line_icd_dgns_cd3=E782 line_icd_dgns_cd4=E782 line_icd_dgns_cd5=E782 line_icd_dgns_cd6=E782 line_icd_dgns_cd7=E782
 line_icd_dgns_cd8=E782 line_icd_dgns_cd9=E782 line_icd_dgns_cd10=E782 line_icd_dgns_cd11=E782 line_icd_dgns_cd12=E782
 line_icd_dgns_cd13=E782 hcpcs_cd1=81161 hcpcs_cd2=81238 hcpcs_cd3=81411 hcpcs_cd4=81413 hcpcs_cd5=81414 hcpcs_cd6=81401
 hcpcs_cd7=81404 hcpcs_cd8=81404 hcpcs_cd9=81404 hcpcs_cd10=81404 hcpcs_cd11=81404 hcpcs_cd12=81405 hcpcs_cd13=81405
 line_nch_pmt_amt1=279.00 line_nch_pmt_amt2=600.00 line_nch_pmt_amt3=1350.19 line_nch_pmt_amt4=584.90 line_nch_pmt_amt5=584.90
 line_nch_pmt_amt6=137.00 line_nch_pmt_amt7=274.83 line_nch_pmt_amt8=274.83 line_nch_pmt_amt9=274.83 line_nch_pmt_amt10=274.83
 line_nch_pmt_amt11=274.83 line_nch_pmt_amt12=301.35 line_nch_pmt_amt13=301.35 prf_physn_npi1=1386023620 prf_physn_npi2=1386023620
 prf_physn_npi3=1386023620 prf_physn_npi4=1386023620 prf_physn_npi5=1386023620 prf_physn_npi6=1386023620 prf_physn_npi7=1386023620
 prf_physn_npi8=1386023620 prf_physn_npi9=1386023620 prf_physn_npi10=1386023620 prf_physn_npi11=1386023620 prf_physn_npi12=1386023620
 prf_physn_npi13=1386023620 tax_num1=472935323 tax_num2=472935323 tax_num3=472935323 tax_num4=472935323 tax_num5=472935323
 tax_num6=472935323 tax_num7=472935323 tax_num8=472935323 tax_num9=472935323 tax_num10=472935323 tax_num11=472935323
 tax_num12=472935323 tax_num13=472935323 BENE_ID=eeeeee119111E11 CLM_ID=eeeeJ9jJE9reaEa LINE_NUM=14 CLM_THRU_DT=15APR2021
 PRF_PHYSN_NPI=1386023620 TAX_NUM=472935323 LINE_1ST_EXPNS_DT=15APR2021 LINE_LAST_EXPNS_DT=15APR2021 HCPCS_CD=81406
 LINE_NCH_PMT_AMT=282.88 LINE_ICD_DGNS_CD=E782 Year=2021 Case=Lines FIRST.BENE_ID=0 LAST.BENE_ID=0 FIRST.CLM_ID=0 LAST.CLM_ID=0
 FIRST.LINE_NUM=1 LAST.LINE_NUM=1 i=. _ERROR_=1 _N_=5808
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: There were 5809 observations read from the data set WORK.BCARLINE2016_2021.
 WARNING: The data set WORK.BCARLINE2016_2021_WIDE may be incomplete.  When this step was stopped there were 3237 observations and 
          96 variables.
 WARNING: Data set WORK.BCARLINE2016_2021_WIDE was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.01 seconds
       cpu time            0.02 seconds
       
 
 132        
 133        
 134        
 135        
 136        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 148        

What do I do?

 

 

 

Kurt_Bremser
Super User

You must also use 50 in the array definitions.

 

The DO loop is not necessary at all when using CALL MISSING with OF:

if first.clm_id then call missing(
  of xline_icd_dgns_cd(*)
  ,of xline_1st_expns_dt_(*)
  ,of xline_last_expns_dt_(*)
  ,of xhcpcs_cd(*)
  ,of xline_nch_pmt_amt(*)
  ,of xprf_physn_npi(*) 
  ,of xtax_num(*) 
);
CathyVI
Lapis Lazuli | Level 10

@Kurt_Bremser @Tom @PaigeMiller @ballardw Thank you. With the 50 in the array definitions, I am having space issue and I have been asked to modify/adjust the code for efficiencies so as not risk a shut down of the system. Please any help on adjusting the code. 

Tom
Super User Tom
Super User

@CathyVI wrote:

@Kurt_Bremser @Tom @PaigeMiller @ballardw Thank you. With the 50 in the array definitions, I am having space issue and I have been asked to modify/adjust the code for efficiencies so as not risk a shut down of the system. Please any help on adjusting the code. 


Most likely it is that transpose step that is making the dataset so large because of all of the empty values you now need to store.

 

Look at the overall goal of your analysis.  In general moving data from "tall" structure to "wide" structure like that makes the data harder to work with (in addition to taking more space.) So why are you doing it?

Kurt_Bremser
Super User

Maxim 19: Long Beats Wide.

In 99 % of cases encountered here on the communities, transposing from long to wide is not necessary and in fact detrimental to the task at hand.

Why do you think you need the wide structure?

PaigeMiller
Diamond | Level 26

You can't refer to element 14 of an array that is defined to have 13 elements. You must make the array larger to cover all possible values of the variable line_num

--
Paige Miller
PaigeMiller
Diamond | Level 26

With the code below, line_num max=50. Do I use 50 in the do statement?

 

As I said, you have to define the arrays to be length that is the maximum value of line_num, which you tell us is 50. That will eliminate this particular error, but may not eliminate other errors and may not provide sensible results. As I don't have your data, and as I don't understand the purpose of the program, I can't say anything further. You need to understand what the program is doing, and you need to determine if this change will make sense and provide correct answers.

--
Paige Miller
Tom
Super User Tom
Super User

No.  Instead use the 50 when defining the arrays.

 

And you don't need the DO loop at all.  You can either use CALL MISSING() to clear the retained values. Or even easier use a different DO loop.  One that encloses the SET statement so that there is no need to retain the values and so no need to clear them.

 

There is no need to attach the $ formats to the character variables. It is really only in that original program as a way to TRICK the data step into setting the storage length for the character variables.  Instead just specify the desired LENGTH of the variables when defining them in the ARRAY statement.  

 

Here is the idea (you can fill in the rest of the array and assignment statements).

/* STEP 5.2: TRANSFORM CARRIER LINE FILE */
proc sql;
select max(line_num) into :n trimmed
from bcarline2016_2021;
quit;

data bcarline2016_2021_wide;
do until(last.clm_id);
  set bcarline2016_2021;
  by bene_id clm_id line_num;

  array xline_icd_dgns_cd $5 line_icd_dgns_cd1-line_icd_dgns_cd&n;
  array xline_1st_expns_dt_ 8 line_1st_expns_dt_1-line_1st_expns_dt_&n; 
  ...

  if not missing(line_num) then do;
    xline_icd_dgns_cd[line_num]=line_icd_dgns_cd;
    xline_1st_expns_dt_[line_num]=line_1st_expns_dt; 
   ...
  end;
end;
  format line_1st_expns_dt_1-line_1st_expns_dt_&n
         line_last_expns_dt_1-line_last_expns_dt_&n  mmddyy10.
  ;

  drop i line_1st_expns_dt line_last_expns_dt hcpcs_cd line_icd_dgns_cd 
       line_num line_nch_pmt_amt prf_physn_npi tax_num 
  ;
run;

 

PaigeMiller
Diamond | Level 26

This code I found in the book SAS® Programming with Medicare Administrative Data, and this was similar to the data am using except my data is from 2016-2021.

 

So to summarize, the code doesn't work, it doesn't make sense to us, and it is inefficient. I think you would be wise to simply start over and write your own code and work with a long data set.

--
Paige Miller
Kurt_Bremser
Super User

This does not make sense:

	do i=1 to 13;
		xline_icd_dgns_cd(line_num)='';
		xline_1st_expns_dt_(line_num)=.; 
		xline_last_expns_dt_(line_num)=.; 
		xhcpcs_cd(line_num)=''; 
		xline_nch_pmt_amt(line_num)=.;  
		xprf_physn_npi(line_num)='';   
		xtax_num(line_num)='';  
	end;

Why do you set the same array elements to blank 13 times in succession?

I guess you wanted to use i as array index.

 

Run

proc sql;
select max(line_num)
from bcarline2016_2021,
quit;

to see how large your arrays must be.

ballardw
Super User

If this block of code is supposed to set all the elements of multiple arrays to missing

 101        do i=1 to 13;
 102        xline_icd_dgns_cd(line_num)='';
 103        xline_1st_expns_dt_(line_num)=.;
 104        xline_last_expns_dt_(line_num)=.;
 105        xhcpcs_cd(line_num)='';
 106        xline_nch_pmt_amt(line_num)=.;
 107        xprf_physn_npi(line_num)='';
 108        xtax_num(line_num)='';
 109        end;

Then there is no reason to loop over the individual elements. One statement will do:

call missing(
       of xline_icd_dgns_cd(*)
		,of xline_1st_expns_dt_(*)
		,of xline_last_expns_dt_(*)
		,of xhcpcs_cd(*)
		,of xline_nch_pmt_amt(*)
		,of xprf_physn_npi(*) 
		,of xtax_num(*) 
            ); 

call missing is a special function whose purpose is to set variables to missing. As such it knows the difference between numeric and character values so you don't have to have a bunch of =. or =''. Also just like many of the functions that accept lists of values it will handle syntax "of arrayname(*)" to use all the elements of an array. This is very nice as you don't have to change an array index value if the size of the array changes.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 12 replies
  • 2500 views
  • 8 likes
  • 5 in conversation