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

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

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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

2 REPLIES 2
BrunoMueller
SAS Super FREQ

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

 

daszlosek
Quartz | Level 8
Yes! The S modifier helped with the carriage return issue! Thank you!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 2 replies
  • 1442 views
  • 0 likes
  • 2 in conversation