DATA Step, Macro, Functions and more

Findw does not 'find' after line breaks

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 79
Accepted Solution

Findw does not 'find' after line breaks

[ Edited ]

I am trying to pull in results from an excel file that has a column that is free text and figure out if I word is in that text. It appears as though where the line break is within the excel file is where the data is getting cut off.

 

For example (in excel):

"CHOCOLATE  PRESENT MANY (>30):

VANILLA  PRESENT MANY (>30):

CARAMEL PRESENT MANY (>30):"

 

The proc import that I used is the following:

 

PROC IMPORT OUT= shelter_3 DATAFILE= "/shares/candy.xlsx" 
            DBMS=xlsx REPLACE;
     /*SHEET="auto";*/ 
     GETNAMES=YES;
RUN;

 

When I see the imported file, the only line I see is the following:

"CHOCOLATE  PRESENT MANY (>30):"

 

But if I double click I see all the text. 

 

I then use the following pull out the flavor:

CHOC= findw(Text_field, 'CHOCOLATE');
VAN= findw(Text_field, 'VANILLA');
CARA= findw(Text_field, 'CARAMEL');

 

But the only once that is not zero is chocolate. It is as if the findw can't read past the line break

 

 

 

 

 


Accepted Solutions
Solution
‎01-10-2018 09:37 AM
SAS Super FREQ
Posts: 810

Re: Findw does not 'find' after line breaks

Posted in reply to daszlosek

Would the FIND function do what you want?

 

Otherwise use the the FINDW as follows:

VAN= findw(text_Field, 'VANILLA', "", "S");

The S modifier adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, and form feed) to the list of characters

 

View solution in original post


All Replies
Solution
‎01-10-2018 09:37 AM
SAS Super FREQ
Posts: 810

Re: Findw does not 'find' after line breaks

Posted in reply to daszlosek

Would the FIND function do what you want?

 

Otherwise use the the FINDW as follows:

VAN= findw(text_Field, 'VANILLA', "", "S");

The S modifier adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, and form feed) to the list of characters

 

Frequent Contributor
Posts: 79

Re: Findw does not 'find' after line breaks

Posted in reply to Bruno_SAS
Yes! The S modifier helped with the carriage return issue! Thank you!
☑ This topic is solved.

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

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