<?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 put from macro called by data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88569#M257174</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example I have this Macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Excel(type=,row=,column=,data=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=excel %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file "C:\temp\excel.vbs";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=setcell %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put "XL.Cell(&amp;amp;row, &amp;amp;column).Value = ""&amp;amp;data"" ";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=create %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x "C:\temp\excel.vbs";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then i do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Excel(type=excel);&lt;/P&gt;&lt;P&gt;%Excel(type=setcell, row=1, column=1, data=Test);&lt;/P&gt;&lt;P&gt;%Excel(type=create);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just example, my macro is much more bigger and works like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But now I'd like to set some cells with data from within a Data-Set..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I made myself a temporary close call and open call (with append) (Cause otherwise he repeats the puts from above)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=savetemp %then run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=opentemp %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file "C:\temp\excel.vbs" mod; &lt;/P&gt;&lt;P&gt;&amp;nbsp; %end; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in my normal code I do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Excel(type=savetemp);&lt;/P&gt;&lt;P&gt;%Excel(type=opentemp);&lt;/P&gt;&lt;P&gt;set MyDataSet;&lt;/P&gt;&lt;P&gt;retain row 2;&lt;/P&gt;&lt;P&gt;row=row+1;&lt;/P&gt;&lt;P&gt;%Excel(type=setcell, row=row, column=1, data=MyVariable);&lt;/P&gt;&lt;P&gt;%Excel(type=create);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works but it sets ALL put's to the same values. So all row's will be set to the last..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I tried to do it with a call execute, then I get a Error put =&amp;gt; "Statement is not valid or it is used out of proper order", I think cause it's not getting executed within the data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Ideas? &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Jan 2013 17:00:32 GMT</pubDate>
    <dc:creator>Raphael_</dc:creator>
    <dc:date>2013-01-28T17:00:32Z</dc:date>
    <item>
      <title>put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88569#M257174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example I have this Macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Excel(type=,row=,column=,data=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=excel %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file "C:\temp\excel.vbs";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=setcell %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put "XL.Cell(&amp;amp;row, &amp;amp;column).Value = ""&amp;amp;data"" ";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=create %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x "C:\temp\excel.vbs";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then i do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Excel(type=excel);&lt;/P&gt;&lt;P&gt;%Excel(type=setcell, row=1, column=1, data=Test);&lt;/P&gt;&lt;P&gt;%Excel(type=create);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just example, my macro is much more bigger and works like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But now I'd like to set some cells with data from within a Data-Set..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I made myself a temporary close call and open call (with append) (Cause otherwise he repeats the puts from above)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=savetemp %then run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if type=opentemp %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file "C:\temp\excel.vbs" mod; &lt;/P&gt;&lt;P&gt;&amp;nbsp; %end; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in my normal code I do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Excel(type=savetemp);&lt;/P&gt;&lt;P&gt;%Excel(type=opentemp);&lt;/P&gt;&lt;P&gt;set MyDataSet;&lt;/P&gt;&lt;P&gt;retain row 2;&lt;/P&gt;&lt;P&gt;row=row+1;&lt;/P&gt;&lt;P&gt;%Excel(type=setcell, row=row, column=1, data=MyVariable);&lt;/P&gt;&lt;P&gt;%Excel(type=create);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works but it sets ALL put's to the same values. So all row's will be set to the last..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I tried to do it with a call execute, then I get a Error put =&amp;gt; "Statement is not valid or it is used out of proper order", I think cause it's not getting executed within the data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Ideas? &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2013 17:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88569#M257174</guid>
      <dc:creator>Raphael_</dc:creator>
      <dc:date>2013-01-28T17:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88570#M257175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the problematic line is the below one?&lt;/P&gt;&lt;PRE&gt;put "XL.Cell(&amp;amp;row, &amp;amp;column).Value = ""&amp;amp;data"" ";
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is you would get a valued of "MyVariable" from the put statement.&amp;nbsp; Assuming MyVariable is a varible name, and you want the value of that variable, then maybe you want something like:&lt;/P&gt;&lt;PRE&gt;put "XL.Cell(&amp;amp;row, &amp;amp;column).Value = " &amp;amp;data;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or i guess if you need to have quotes is the value, perhaps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;put "XL.Cell(&amp;amp;row, &amp;amp;column).Value = """&amp;amp;data'"';
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is, your wouldn't want quotes around &amp;amp;data, since you want the value of the variable it names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2013 17:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88570#M257175</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-01-28T17:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88571#M257176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That looks like the right statement to work on, but I think the problem is referring to &amp;amp;ROW.&amp;nbsp; That will never change, thus you get the same row each time.&amp;nbsp; You need to revamp the PUT statement so that it writes out the value of the DATA step variable ROW, instead of &amp;amp;ROW.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2013 17:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88571#M257176</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-01-28T17:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88572#M257177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good point, I picked wrong.&amp;nbsp; Maybe you want both the value of dataset varible row and value of dtaset varible MyVariable???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess if you want the value of the dataset variable row, could do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;put "XL.Cell(" &amp;amp;row ",&amp;amp;column).Value = ""&amp;amp;data"" ";
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2013 18:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88572#M257177</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-01-28T18:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88573#M257178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is actually not this line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cause as I call it from normal code, it works fine. Just as I like to call the Macro from within a Data Step it fails as I described.. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 08:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88573#M257178</guid>
      <dc:creator>Raphael_</dc:creator>
      <dc:date>2013-01-29T08:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88574#M257179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay I got it to work, I changed my whole Macro, Now i'm filling up a dataset with proc sql; insert into; so I can call it also from within a datastep. At the end I'm filling up my file with the obs from the dataset and start the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Little bit weird, but works &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 10:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88574#M257179</guid>
      <dc:creator>Raphael_</dc:creator>
      <dc:date>2013-01-29T10:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: put from macro called by data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88575#M257180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That surely is the problem.&amp;nbsp; The macro is just doing text substitution.&amp;nbsp; If you call it with ROW=ROW it will replace &amp;amp;ROW with ROW.&amp;nbsp; But you want it to replace &amp;amp;ROW with a number.&amp;nbsp; Since it is generating a PUT statement if you get the generated reference to the ROW dataset variable out of the quotes then the PUT statement will replace the name of the variable with the value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 13:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/put-from-macro-called-by-data-step/m-p/88575#M257180</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-29T13:41:44Z</dc:date>
    </item>
  </channel>
</rss>

