DATA Step, Macro, Functions and more

contain(1)

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

contain(1)

I read variable=contain(1)......

IS it posibble to write theassignement above?


Accepted Solutions
Solution
‎05-03-2016 07:40 AM
Super User
Posts: 5,504

Re: contain(1)

[ Edited ]

If you read this as part of a SAS program, it means a DATA step contains an array named CONTAIN.  That statement would assign (as the value of VARIABLE) the first element in the array.

View solution in original post


All Replies
Super User
Super User
Posts: 7,955

Re: contain(1)

Hi,

 

Could you be a little bit more verbose in the description of the problem, perhaps posting example test data (form of a datastep) and what the output should look like.  I am going to guess that 1 is a character, and you want to search in a string of characters to see if that character exists and if so assign a boolean response to variable 1 being found, 0 not being found:

data have;
input a $;
b=ifn(findc(a,"1") > 0,1,0);
datalines;
045674
341232
run;
Solution
‎05-03-2016 07:40 AM
Super User
Posts: 5,504

Re: contain(1)

[ Edited ]

If you read this as part of a SAS program, it means a DATA step contains an array named CONTAIN.  That statement would assign (as the value of VARIABLE) the first element in the array.

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 287 views
  • 0 likes
  • 3 in conversation