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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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