BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

Hi everyone,

 

I have a Word document with lots of text which I need to add as a tab to an existing Excel document using SAS.

 

I came up with an approach that I thought would work:

1. Save the Word doc as a text file (.txt)

2. Read into SAS as a SAS dataset with a long variable called Label to hold all the text in each line.

3. Add a variable called Start which is a record counter.

4. Use PROC FORMAT with CNTLIN to make a format out of those values. 

5. Output to Excel a dataset of numbers 1-(number of records) that are formatted using the format in 4.

 

But then I remembered that the original Word document has a flowchart/image in the middle of the document. This obviously complicates things, so now I'm not sure what the best approach would be. 

 

Any help is much appreciated.

3 REPLIES 3
andreas_lds
Jade | Level 19
Not using sas seems to be the best approach I can think of. Sas is a great tool to process data, but imho not the right choice to process documents.
ballardw
Super User

I have no clue why you think SAS should be involved with this.

 

If I thought I needed such I would try copy and paste the whole Word doc into Excel. Reformat the column all the text will end up in.

May need a separate copy/paste for the image to get in a desirable location.

 

If the document has any tables you might have lots of fun just getting the text read.

Reeza
Super User
There's a variety of Microsoft solutions VBA/VBS/OLE that may enable this type of functionality. However, in my experience it doesn't show as nicely formatted so if appearance matters this doesn't work and you need to ensure it's formatted correctly first. If that's not an issue then you can find the VBA/VBS solution and then call it from SAS.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 671 views
  • 3 likes
  • 4 in conversation