<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: import a word doc then output with same format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431390#M106708</link>
    <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will try both way!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2018 18:28:23 GMT</pubDate>
    <dc:creator>GeorgeSAS</dc:creator>
    <dc:date>2018-01-26T18:28:23Z</dc:date>
    <item>
      <title>import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431352#M106689</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to import a MS word .doc file into SAS ,after do simple change then&amp;nbsp;export it to a new .doc file. but I want keep same format as the old one.format including font size,color paragraphs everything.&lt;/P&gt;
&lt;P&gt;can I do it in SAS? or any other method?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I attached an sample&amp;nbsp;doc file(sample.doc) here. I want import it into SAS and change&amp;nbsp;June 12, 2006 to&amp;nbsp;June 16, 2016 then export to a new file named newfile.doc with same format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431352#M106689</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T17:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431359#M106691</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10531"&gt;@GeorgeSAS&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to import a MS word .doc file into SAS ,after do simple change then&amp;nbsp;export it to a new .doc file. but I want keep same format as the old one.format including font size,color paragraphs everything.&lt;/P&gt;
&lt;P&gt;can I do it in SAS? or any other method?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I attached an sample&amp;nbsp;doc file(sample.doc) here. I want import it into SAS and change&amp;nbsp;June 12, 2006 to&amp;nbsp;June 16, 2016 then export to a new file named newfile.doc with same format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Basically ain't gonna happen with SAS. DOC or DOCX file formats are not intended for data interchange SAS is intended to read data. You would have to write an entire&amp;nbsp;Word document parser to do what it sounds like you want to accomplish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might be better of with some sort of Microsoft Visual Basic or VBA code or macro.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431359#M106691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-26T17:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431364#M106694</link>
      <description>&lt;P&gt;Doc or DocX?&lt;/P&gt;
&lt;P&gt;If you're changing a single value in a docx files there are ways...a doc file however is pretty locked down.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I second the suggestion of using a VBS or VBA script instead. You can call it from SAS or even write it from SAS if so desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431364#M106694</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-26T17:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431366#M106695</link>
      <description>&lt;P&gt;I will change the sample.doc to sample.xml. then I will import it into SAS. after modification then export it to newfile.doc.&lt;BR /&gt;&lt;BR /&gt;now the thing is how to import sample.xml into SAS, I am working on it now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is the sample.xml in attachement, please help the code of importing it to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(&lt;/P&gt;
&lt;UL id="list_0" class="lia-list-standard"&gt;
&lt;LI&gt;The file sample.xml does not have a valid extension for an attachment and has been removed. sas,txt,csv,zip,pdf,ics,sx,sxs,doc,docx,xls,xlsx,egp,sav,sas7bdat,ctm,ctk,rtf,py are the valid extensions.)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;it can't be attached, please just simply rename .doc to .xml.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need1;
infile "c:\temp\sample.xml"  truncover pad ;
input source $10000.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431366#M106695</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T18:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431368#M106696</link>
      <description>&lt;P&gt;That works for DOCX files, after you unzip it, but not for DOC files. Which do you have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;GeorgeSAS wrote:&lt;/P&gt;
&lt;BR /&gt;I will change the sample.doc to sample.xml. then I will import it into SAS. after modification then export it to newfile.doc.&lt;BR /&gt;&lt;BR /&gt;now the thing is how to import xml into SAS, I am working on it now.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431368#M106696</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-26T17:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431369#M106697</link>
      <description>&lt;P&gt;sample.doc file&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431369#M106697</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T17:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431377#M106702</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10531"&gt;@GeorgeSAS&lt;/a&gt;&amp;nbsp;You attachments aren't working. Save it as xml and change the extension to txt to upload it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431377#M106702</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-26T18:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431383#M106703</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data need1;
infile "c:\temp\sample.xml" truncover pad ;
input source $10000.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431383#M106703</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T18:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431386#M106704</link>
      <description>&lt;P&gt;So that text file has content, including the word Georgia in some places. If I change the txt to XML, there's no more word Georgia in the file, so as far as I can see, that approach will not work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You still haven't said if this is a doc or docx file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431386#M106704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-26T18:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431388#M106706</link>
      <description>not just simply change .doc to .xml.&lt;BR /&gt;opend .doc file  then save as .xml file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank!</description>
      <pubDate>Fri, 26 Jan 2018 18:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431388#M106706</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T18:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431389#M106707</link>
      <description>&lt;P&gt;The proper tool for manipulating&amp;nbsp;&lt;EM&gt;Word&lt;/EM&gt; documents is&amp;nbsp;&lt;EM&gt;MS Word&lt;/EM&gt;. Use a VBA script with Word.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431389#M106707</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-26T18:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431390#M106708</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will try both way!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431390#M106708</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T18:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431393#M106709</link>
      <description>&lt;P&gt;If I do that I'll get a different file. I'm saying YOU&amp;nbsp;should do that, create YOUR XML file, change the extension to txt and upload it.&lt;/P&gt;
&lt;P&gt;How are you planning to automate that step by the way? And if you have to use VBA why bother with SAS at all...?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10531"&gt;@GeorgeSAS&lt;/a&gt; wrote:&lt;BR /&gt;not just simply change .doc to .xml.&lt;BR /&gt;opend .doc file then save as .xml file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 18:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431393#M106709</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-26T18:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: import a word doc then output with same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431477#M106739</link>
      <description>&lt;P&gt;first method: SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I open the .doc file and save it as .html file then do the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;filename in "C:\temp\sample.htm";

data sashelp.testsample;
 infile in pad missover lrecl=300;
 input source $200.;
 run;

 
data need;
set sashelp.testsample;
year=year(date());
call symput('applyYear',strip(year-1));
run;

data need;
set need;
if index(source,"June 12, 2006") then do;
source=tranwrd(source,'2006',year);
end;

run;

  filename out "C:\temp\samplenew.doc";
data _null_;
 file out;
 set need;
 put source ;
 run;&lt;BR /&gt;&lt;BR /&gt;The new .doc file is I need, change the view from web view to print view when open it in MS word.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second method: VBA:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;see attachment sampleVBA&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;the two arrows will change the year between 2006 and 2016.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;the VBA is very simple .need add more feature&amp;nbsp;to make the function better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;for example if I want change the year to current year ......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 23:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-a-word-doc-then-output-with-same-format/m-p/431477#M106739</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2018-01-26T23:17:57Z</dc:date>
    </item>
  </channel>
</rss>

