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

Hello,

I would like to search 'ECZEMA' in the six columns from string1 to string6.  Then I tried to run a do loop command.  But an error message was shown in the log window.  Please help, thank you.

data want;
	set have ;	
	array string_{*} String1 - String6;
	  do i = 1 to 6;
	if prxmatch('/ECZEMA/i',string_) then allergy=1;
	end;
run;

 

The error messages were list below, and also why in the 'Note' statement, 'Numeric values have been converted to character values?'

 

ERROR: Illegal reference to the array string_.

NOTE: Numeric values have been converted to character values at the places given by:

(Line):(Column).

105:38 106:38 107:42 108:47 109:27 110:34 111:34 113:44

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.have may be incomplete. When this step was

stopped there were 0 observations and 18 variables.

WARNING: Data set WORK.have was not replaced because this step was

stopped.

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

You miss the index to array member.

May be next code will work

data want;
	set have ;	
	array string_{*} String1 - String6;
	  do i = 1 to 6;
	if prxmatch('/ECZEMA/i',string_(i)) then allergy=1;
	end;
run;

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

You can try next code:

data want;
	set have ;	
	array string_{*} String1 - String6;
	 do i = 1 to 6;
	    if upcase(string_(i)) = "ECZEMA" then allergy=1;
	end;
run;
ybz12003
Rhodochrosite | Level 12

I have multiple prematching texts, which are not just 'ECZEMA,'

Shmuel
Garnet | Level 18

You miss the index to array member.

May be next code will work

data want;
	set have ;	
	array string_{*} String1 - String6;
	  do i = 1 to 6;
	if prxmatch('/ECZEMA/i',string_(i)) then allergy=1;
	end;
run;
PGStats
Opal | Level 21

You forgot the index in your array reference

 

if prxmatch('/ECZEMA/i', string_{i}) then allergy = 1;

PG

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
  • 4 replies
  • 1448 views
  • 1 like
  • 3 in conversation