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

Hi, 

 

 I want to find a sales reference in a PDF document. The sales reference is formatted like ACC/19000101/001, etc. In the document, txt_array{i} represents a word. I need to determine if txt_array[i] starts with a prefix such as ACC or DCA, which are stored in a macro variable codes. I encountered an error, screenshots of the error are provided below.

 

SYMBOLGEN:  Macro variable CODES resolves to 
            'ACC','DCA','DCB','DCC','CNA'
NOTE: Line generated by the invoked macro "PROCESS_SALES".
6752                    if (symget('refcode') = "") and (find(txt_array[i],&codes)>0) then     call
                                                          ____
                                                          72
6752     ! symputx('refcode',txt_array{i});          
ERROR 72-185: The FIND function call has too many arguments.

How can I fix this?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I need to determine if txt_array[i] starts with a prefix

So no need to use FIND for that test.  In normal SAS you canuse the colon modifier on the comparison operator to have the comparison truncated to the length of the shorter string. 

 

So in this case use it on the IN operator.

txt_arrya[i] in: ('ACC','DCA','DCB','DCC','CNA') 

 

PS SAS does not care if you use spaces or commas between the items in the list of values for the IN operator.  So it will be easier if you set CODES like this :

%let codes='ACC' 'DCA' 'DCB' 'DCC' 'CNA';

since it is much easier to use macro variables with spaces than macro variables with commas.

View solution in original post

3 REPLIES 3
Reeza
Super User

Hard to say exactly without full code, but it looks like you're passing multiple comma delimited quoted words to the find function, eg.

 

 

find(txt_array[i],&codes)>0

Becomes the following which is invalid.

 

 

find(txt_array[i],'ACC','DCA','DCB','DCC','CNA')>0)

 

Depending on the rest of your program  and requirements you could add double quotes around the variable or you may need to iterate through the codes. Unsure of requirements here.

 

find(txt_array[i],"&codes")>0

@WenjieZhou2021 wrote:

Hi, 

 

 I want to find a sales reference in a PDF document. The sales reference is formatted like ACC/19000101/001, etc. In the document, txt_array{i} represents a word. I need to determine if txt_array[i] starts with a prefix such as ACC or DCA, which are stored in a macro variable codes. I encountered an error, screenshots of the error are provided below.

 

SYMBOLGEN:  Macro variable CODES resolves to 
            'ACC','DCA','DCB','DCC','CNA'
NOTE: Line generated by the invoked macro "PROCESS_SALES".
6752                    if (symget('refcode') = "") and (find(txt_array[i],&codes)>0) then     call
                                                          ____
                                                          72
6752     ! symputx('refcode',txt_array{i});          
ERROR 72-185: The FIND function call has too many arguments.

How can I fix this?

 

Thanks

 


 

 

Tom
Super User Tom
Super User

I need to determine if txt_array[i] starts with a prefix

So no need to use FIND for that test.  In normal SAS you canuse the colon modifier on the comparison operator to have the comparison truncated to the length of the shorter string. 

 

So in this case use it on the IN operator.

txt_arrya[i] in: ('ACC','DCA','DCB','DCC','CNA') 

 

PS SAS does not care if you use spaces or commas between the items in the list of values for the IN operator.  So it will be easier if you set CODES like this :

%let codes='ACC' 'DCA' 'DCB' 'DCC' 'CNA';

since it is much easier to use macro variables with spaces than macro variables with commas.

WenjieZhou2021
Calcite | Level 5

Thank you, it's working!

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
  • 3 replies
  • 458 views
  • 4 likes
  • 3 in conversation