<?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: Macros and DDE. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26730#M4789</link>
    <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
enclose the desired command into double quotes (for the macros inside it to be resolved), then follow this general rules for the enclosed text:&lt;BR /&gt;
&lt;BR /&gt;
- two consecutive double ( "" ) quotes for each single one ( " )&lt;BR /&gt;
- one single quote ( ' ) for each single one ( ' )&lt;BR /&gt;
&lt;BR /&gt;
Some examples:&lt;BR /&gt;
[pre]"""whatever"""&lt;BR /&gt;
"'whatever'"&lt;BR /&gt;
"""whatever"&lt;BR /&gt;
"""""whatever"""""[/pre]&lt;BR /&gt;
Which will resolve (same order) to:&lt;BR /&gt;
[pre]"whatever"&lt;BR /&gt;
'whatever'&lt;BR /&gt;
"whatever&lt;BR /&gt;
""whatever""[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
    <pubDate>Tue, 26 Jan 2010 12:04:13 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2010-01-26T12:04:13Z</dc:date>
    <item>
      <title>Macros and DDE.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26727#M4786</link>
      <description>I could try, but maybe someone already have tried, and knows.&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to use macros in combination with DDE, when transferring data to Excel?&lt;BR /&gt;
&lt;BR /&gt;
If the expression is: filename area 'excel|[XLWb.xls]Sheet1!r10c2:r20c30';&lt;BR /&gt;
&lt;BR /&gt;
The next time it should be: filename area 'excel|[XLWb.xls]Sheet2!r10c2:r20c30';,&lt;BR /&gt;
&lt;BR /&gt;
and so on. It would save code lines if there were 12 sheets and I could use a macro variable x, with values &amp;amp;x from 1 to 12.&lt;BR /&gt;
&lt;BR /&gt;
Could there be Sheet&amp;amp;x inside ' ', or must the whole text line be generated?&lt;BR /&gt;
&lt;BR /&gt;
And expressions like: put '[select("r10c1:r10c5")]';.&lt;BR /&gt;
&lt;BR /&gt;
Is it then possible to change only the column numbers with a macro variable, let's say y, and have an expression:&lt;BR /&gt;
&lt;BR /&gt;
put '[select("r10c1:r10c%eval(&amp;amp;y+5)")]';?</description>
      <pubDate>Mon, 07 Dec 2009 10:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26727#M4786</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-07T10:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and DDE.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26728#M4787</link>
      <description>Hi:&lt;BR /&gt;
  Macro variable refereces will not resolve  within single quotes, however, you can use macro quoting functions and other coding techniques to get around that limitation. I don't work with DDE that much, so my programming needs for examples have not required SAS macro programs. However, I believe if you perform a Google search using the string:&lt;BR /&gt;
SAS Excel DDE macro program&lt;BR /&gt;
you will come up with quite a few hits, this among them:&lt;BR /&gt;
&lt;A href="http://analytics.ncsu.edu/sesug/2003/DM08-Li.pdf" target="_blank"&gt;http://analytics.ncsu.edu/sesug/2003/DM08-Li.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 07 Dec 2009 15:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26728#M4787</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-12-07T15:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and DDE.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26729#M4788</link>
      <description>If you're still working on it, here is how to use macro variables in your DDE commands:&lt;BR /&gt;
put "[select(""r10c1:r10c%eval(&amp;amp;y+5)"")]";&lt;BR /&gt;
Please note that &lt;BR /&gt;
 - ' has been replaced by " &lt;BR /&gt;
 - " has been replaced by ""&lt;BR /&gt;
Good luck</description>
      <pubDate>Tue, 26 Jan 2010 11:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26729#M4788</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-26T11:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and DDE.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26730#M4789</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
enclose the desired command into double quotes (for the macros inside it to be resolved), then follow this general rules for the enclosed text:&lt;BR /&gt;
&lt;BR /&gt;
- two consecutive double ( "" ) quotes for each single one ( " )&lt;BR /&gt;
- one single quote ( ' ) for each single one ( ' )&lt;BR /&gt;
&lt;BR /&gt;
Some examples:&lt;BR /&gt;
[pre]"""whatever"""&lt;BR /&gt;
"'whatever'"&lt;BR /&gt;
"""whatever"&lt;BR /&gt;
"""""whatever"""""[/pre]&lt;BR /&gt;
Which will resolve (same order) to:&lt;BR /&gt;
[pre]"whatever"&lt;BR /&gt;
'whatever'&lt;BR /&gt;
"whatever&lt;BR /&gt;
""whatever""[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Tue, 26 Jan 2010 12:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26730#M4789</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-26T12:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and DDE.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26731#M4790</link>
      <description>Another solution is to use the FILEVAR= option on the FILE statement.  When writing to files on disk, FILEVAR= enables you to write to several files from one DATA step.  The same is true when using FILEVAR= with DDE.  It enables you to process several DDE commands from one DATA step.&lt;BR /&gt;
&lt;BR /&gt;
Here is an example where Sheet1, Sheet2, and Sheet3 are filled with two columns and 10 rows of dummy data:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  do i = 1 to 3;&lt;BR /&gt;
    sheet = cats('excel|[test-sheet.xlsx]Sheet', i, '!r1c1:r10c2');&lt;BR /&gt;
    file area dde filevar=sheet;&lt;BR /&gt;
    do x = 1 to 10;&lt;BR /&gt;
      y = 2*x;&lt;BR /&gt;
      put x y;&lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
To me, this solution is simpler because there aren't any macros or macro variables involved.&lt;BR /&gt;
&lt;BR /&gt;
Documentation for FILEVAR= option on FILE statement:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000171874.htm#a000699156" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000171874.htm#a000699156&lt;/A&gt;</description>
      <pubDate>Tue, 26 Jan 2010 18:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-DDE/m-p/26731#M4790</guid>
      <dc:creator>JasonS_SAS</dc:creator>
      <dc:date>2010-01-26T18:55:07Z</dc:date>
    </item>
  </channel>
</rss>

