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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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