<?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: How to apply macro to data step and proc reg in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178066#M302532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is weird . I can run your code without error. &lt;/P&gt;&lt;P&gt;Post your ERROR log.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 13 Apr 2014 04:29:58 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2014-04-13T04:29:58Z</dc:date>
    <item>
      <title>How to apply macro to data step and proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178063#M302529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wrote the following macro, but the output contains no data. I believe there are syntax problems in the first and second steps.&lt;/P&gt;&lt;P&gt;For the following macro:&lt;/P&gt;&lt;P&gt;1) if I delete step 2 and step 3 code, then running the macro only create 3 empty data sets;&lt;/P&gt;&lt;P&gt;2) if I first manually create 3 data sets, then run the macro (after deleting step 1 and step 3 code), the macro's outputs still contain no results;&lt;/P&gt;&lt;P&gt;3) if I manually do the step 1 and step 2, then run the macro (after deleting step 1 and step 2 code), now I get the excel file which contains the results I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro DiDreg;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*step 1&lt;SPAN style="color: #000000;"&gt;, create 3 new datasets (want_1, want_2, want_3) from originaldata;*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data want_&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set originaldata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if a_&amp;amp;i=2 then delete;&lt;/P&gt;&lt;P&gt;&amp;nbsp; c_&amp;amp;i = a_&amp;amp;i * b;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*step 2&lt;SPAN style="color: #000000;"&gt;, run regression by using want_1, want_2, want_3;*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc reg data=want_&amp;amp;i outest = did_&amp;amp;i tableout noprint;&lt;/P&gt;&lt;P&gt;model y = x b a_&amp;amp;i c_&amp;amp;i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*step 3&lt;SPAN style="color: #000000;"&gt;, export to excel;*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc export dbms = excel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outfile = "C:\folder\DiD_reg.xls"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data=did_&amp;amp;i replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sheet = "did_&amp;amp;i";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%DiDreg;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***********************************************************;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Desired Results:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*step 1, create three datasets;&lt;/P&gt;&lt;P&gt;*want_1 contains variable: y, x, b, c_1, a_1, a_2, a_3;&lt;/P&gt;&lt;P&gt;*want_2 contains variable: y, x, b, c_2, a_1, a_2, a_3;&lt;/P&gt;&lt;P&gt;*want_3 contains variable: y, x, b, c_3, a_1, a_2, a_3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*step 2, run three regressions;&lt;/P&gt;&lt;P&gt;*regession 1: y x b a_1 c_1, and output to did_1;&lt;/P&gt;&lt;P&gt;*regession 2: y x b a_2 c_2, and output to did_2;&lt;/P&gt;&lt;P&gt;*regession 3: y x b a_3 c_3, and output to did_3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*step 3, combine did_1, did_2 and did_3 to excel file 'did_reg';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2014 01:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178063#M302529</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-04-13T01:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply macro to data step and proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178064#M302530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code looks good except:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;*step 1&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;, create 3 new datasets (want_1, want_2, want_3) from originaldata;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;==&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/*step 1&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;, create 3 new datasets (want_1, want_2, want_3) from originaldata;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff; color: #000000;"&gt;use /* */ in macro not * ; as comment&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2014 03:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178064#M302530</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-13T03:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply macro to data step and proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178065#M302531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you for point that out, I have changed in my question. those comments didn't include in my code when I running it though. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2014 04:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178065#M302531</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-04-13T04:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply macro to data step and proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178066#M302532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is weird . I can run your code without error. &lt;/P&gt;&lt;P&gt;Post your ERROR log.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2014 04:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178066#M302532</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-13T04:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply macro to data step and proc reg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178067#M302533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Ksharp. Just found that I also can run my code without error (using the sample data set I created).... Then it must be the problem of my working data set! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2014 04:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-macro-to-data-step-and-proc-reg/m-p/178067#M302533</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-04-13T04:52:09Z</dc:date>
    </item>
  </channel>
</rss>

