BookmarkSubscribeRSS Feed
athapa1183
Obsidian | Level 7

 

i want to know where in the code the line number 1334 , 1355,1376 and 1397 is.

Because i am using a macro, i do not see the line numbers in SAS Log.

 

Is there a way to print the Line numbers in SAS Log while using Macro.

I will appreciate your help in this regard.

 

tt.PNG

 

MY CODE:


options SPOOL symbolgen mprint mlogic NOSOURCE ;

%macro try;

data S13;
Set s11;
Claimno= Scan(substr(string,find(string,'~CLM*')+ 5,20),1,'*');

IF (INDEX(STRING,'NTE*ADD')> 0 OR INDEX(STRING,'NTE*TPO')> 0 ) THEN DO;
Bill_type=substr(String,find(string,'***',100)+3,2);
Freq= substr(String,find(string,'***',100)+8,1);
Cos= substr(String,find(String,'NTE*')+8,2);
Spec_Code = substr(String,find(String,'NTE*')+10,3);
Paid_Amt= Scan((substr(string,find(string,'AMT*D')+6,8)),1,'~');
Paid_date=substr(String,find(string,'DTP*573*D8*')+11,8);
IF (INDEX (STRING,'HI*ABJ')>0 OR INDEX(string,'HI*BJ')>0 ) THEN TYPE = 'I';
IF (INDEX (STRING,'HI*APR')> 0 OR INDEX(string,'HI*PR')>0 ) THEN TYPE = '0';
end;
IF (INDEX(STRING,'NTE*ADD')= 0 and INDEX(STRING,'NTE*TPO')= 0 ) THEN DO;
Bill_type=substr(String,find(string,'***')+3,2);
Freq= substr(String,find(string,'***')+8,1);
Paid_Amt= Scan((substr(string,find(string,'AMT*D')+6,8)),1,'~');
Paid_date=substr(String,find(string,'DTP*573*D8*')+11,8);
IF (INDEX (STRING,'HI*ABJ')>0 OR INDEX(string,'HI*BJ')>0 ) THEN TYPE = 'I';
IF (INDEX (STRING,'HI*APR')> 0 OR INDEX(string,'HI*PR')>0 ) THEN TYPE = '0';
end;

If find(string,'HI*ABK+') >0 then do;
Pr_Diag= Scan(substr(string,find(string,'HI*ABK+' )+ 7,9),1,'~');
end;
else Pr_diag = Scan(substr(string,find(string,'HI*BK+' )+ 6,9),1,'~');


%do i = 1 %to 100;
Lineno=&i.;
LXA=cats("LX*",&i.);
LX =put(lxa,$5.);
f1=cats("LX*",&i.,"~SV2*"); 
k1= put(f1,$9.);
g1=cats("LX*",&i.,"~SV1*"); 
p1= put(g1,$9.) ;
z11= find(string,k1); * Institutional Claims ; 
g11= find(string,p1); * Professional Claims ;

/* Doing this for Institutional Claims */

if z11 ne 0 then do ; * Control the loop so that extra LX lines are not counted ;
b11= SUBstr(string,z11+5,600);
po1 = index(b11,'~LX');
po2 = index(b11,'~HL'); 
po3 = index(b11,'SE');
if po1 eq 0 then po1 = 10000;
if po2 eq 0 then po2 = 10000;
if po3 eq 0 then po3 = 10000;
word1 = min(of po1-po3);
b21 = substr(b11,1,word1);
Rev_Codes = Scan(b21,2,'*') ;
svcCodes = Scan(b21,3,'*') ;
HCPCS=scan(svccodes,2,'+');
if length(Svccodes)>9 then do; * svccodes = HC+99212 no modifiers here;
mod1 = Substr(svccodes,10,2);
end;
if find(b21,'SVD*H8490*')>0 then do;
FIDA_Paid_Amt = Scan(substr(b21,find(b21,'SVD*H8490*'),16),3,'*'); * it will give error message for non FIDA files ;
end;
if find(b21,'SVD*VNS7') > 0 then do;
Line_Paid_Amt= Scan(substr(b21,find(b21,'SVD*VNS7'),16),3,'*') ;
end;
else if find(b21,'SVD*40024*')> 0 then do;
Line_Paid_Amt= Scan(substr(b21,find(b21,'SVD*40024*'),16),3,'*') ;
end;
Line_Paid_Dt1 = substr(b21,find(b21,'DTP*573*D8*')+11,8);
Line_Paid_Dt= input(Line_Paid_Dt1,8.);
DOS1= substr(b21,find(b21,'472*RD8*')+8,17);
Clm_From= input(scan(DOS1,1,'-'),8.);
Clm_To= input(scan(DOS1,2,'-'),8.);
output;
end; * Close the z11 loop;

/* Doing this for Professional Claims */
if g11 ne 0 then do; * Control the loop so that extra LX lines are not counted ;
b11= SUBstr(string,g11+5,600);
pos1 = index(b11,'~LX');
pos2 = index(b11,'~HL'); 
pos3 = index(b11,'SE');
if pos1 eq 0 then pos1 = 10000;
if pos2 eq 0 then pos2 = 10000;
if pos3 eq 0 then pos3 = 10000;
word = min(of pos1-pos3);
b21 = substr(b11,1,word);
SvcCodes = Scan(b21,2,'*') ;
HCPCS=scan(svccodes,2,'+');
mod1 = Substr(svccodes,10,2);
if find(b21,'SVD*H8490*')>0 then do;
FIDA_Paid_Amt = Scan(substr(b21,find(b21,'SVD*H8490*'),16),3,'*'); * it will give error message for non FIDA files ;
end;
if find(b21,'SVD*VNS7') > 0 then do;
Line_Paid_Amt= Scan(substr(b21,find(b21,'SVD*VNS7'),16),3,'*') ;
end;
else if find(b21,'SVD*40024*')> 0 then do;
Line_Paid_Amt= Scan(substr(b21,find(b21,'SVD*40024*'),16),3,'*') ;
end;
Line_Paid_Dt1 = substr(b21,find(b21,'DTP*573*D8*')+11,8);
Line_Paid_Dt= input(Line_Paid_Dt1,8.);
DOS1= substr(b21,find(b21,'472*RD8*')+8,17);
Clm_From= input(scan(DOS1,1,'-'),8.);
Clm_To= input(scan(DOS1,2,'-'),8.);
output;
end; * Close the g11 loop; 
%end;
/* Drop string f1 k1 word1 lxa lx g1 p1 z11 g11 b11 pos1 pos2 pos3 word po1 po2 po3 dos1 svccodes Line_Paid_Dt1 ;*/
RUN;
%mend try;

%try;

7 REPLIES 7
Peter_C
Rhodochrosite | Level 12
If you need to debug the generated code, use the relevant option MFILE, to store the generated code in a file and debug that code. This does not debug the macro, only the generated code.
SASKiwi
PROC Star

The line numbers referred to can be found in your SAS log - they will be on the program statements that call the macro, not on the statements the macro generates, so they are not helpful in fixing the SAS Notes.

 

Searching for the SUBSTR functions in your macro should give you a good idea of where the problem lies.

ballardw
Super User

Your error indicates that you are substr past the end of the variable as shown with this example:

data example;
   string = 'abcdefghigklmno';
   Freq= substr(String,find(string,'h',3)+1,8);
run;

h occurs at postion 8, so substr starts reading at 'i' asking for 8 characters. When then end of the string is encountered at o only 7 have been found.

 

So either your data is not as you expect for at least 4 of your substr calls or you have miss-specified the length.

 

Instead of taking pictures of log entries please just copy the text and paste into a code box opened using the forum's {I} icon (post code that way also to preserve formatting). Then we can point to specifics. Also provide at least a complete error with the entire data and resulting values instead of something in the middle. With that we could possibly guess which substr is the problem based on variables with missing values or have a length less than specified by the substr call.

athapa1183
Obsidian | Level 7
Ok I will try that Thank You

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