DATA Step, Macro, Functions and more

Word function Index()

Accepted Solution Solved
Reply
Super Contributor
Posts: 420
Accepted Solution

Word function Index()

[ Edited ]

Hi,

 

I want to take all records with word "Income" in column Item . And the below code somehow fail! SAS return no record for data Want


	data Want; set Have;
	if Index(item,"Income")=1 ; run;

So I take a row full value ("42700 · Consulting Income") and try to see if SAS work with full value. And SAS correctly pick the row as code below:

	data check1; set PL;
	if Index(item,"42700 · Consulting Income")=1 ; run;

Can anyone help me to correct my original code?

 

Is that caused by the little dot in the string?

 

Thanks

 

HC

 

 


Accepted Solutions
Solution
‎06-01-2017 06:31 PM
PROC Star
Posts: 326

Re: Word function Index()

One means it sees  the only in starting position, so change it to greater than zero, it can find value anywhere

 

if Index(item,"Income")>0

View solution in original post


All Replies
Solution
‎06-01-2017 06:31 PM
PROC Star
Posts: 326

Re: Word function Index()

One means it sees  the only in starting position, so change it to greater than zero, it can find value anywhere

 

if Index(item,"Income")>0

Super Contributor
Posts: 420

Re: Word function Index()

OMG, great thanks to you.
HC
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 116 views
  • 0 likes
  • 2 in conversation