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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1121 views
  • 1 like
  • 3 in conversation