<?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: Macro data to Excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176242#M264681</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tip: try to scale down your code as much as possible. You are likely to have more people helping you if you can avoid us test nested macros etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Oct 2014 11:33:56 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2014-10-08T11:33:56Z</dc:date>
    <item>
      <title>Macro data to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176241#M264680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the code below (1.) of which produces the data required and exports to excel when I tell it where to go. The code below that (2.) is where I have used a macro to look at populating the latest blank column from the most updated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - I have the column 51-54 updated with August data, I now need to automatically populate the next 4 colums with Septembers data. Thats what im trying to achieve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;1. Manual Code which stipulates the output location, this works- &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro freqit(var);&lt;BR /&gt;proc freq data=Additional_Dataset;&lt;BR /&gt;table &amp;amp;var./out=&amp;amp;var._count missing norow nocol nocum nopercent;&lt;BR /&gt;run;&lt;BR /&gt;data &amp;amp;var._count(drop=&amp;amp;var.);&lt;BR /&gt;set &amp;amp;var._count;&lt;BR /&gt;where &amp;amp;var.=1;&lt;BR /&gt;percent=percent/100;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%freqit(performing);&lt;BR /&gt;%freqit(Performing_Arr_Elsewhere);&lt;BR /&gt;%freqit(non_performing);&lt;BR /&gt;data all_new_asset_type_volume;&lt;BR /&gt;set &lt;BR /&gt;performing_count&lt;BR /&gt;Performing_Arr_Elsewhere_count&lt;BR /&gt;non_performing_count;&lt;BR /&gt;run;&lt;BR /&gt;filename odata dde&lt;BR /&gt;"Excel|G:\Mortgages\Optimum\Reporting Challenger\[Co-Op MI Credit Risk.xlsx]Dashboard Data!R5C51:R7C52" notab ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;SET all_new_asset_type_volume;&lt;BR /&gt;FILE odata dlm='09'x;&lt;BR /&gt;PUT count percent;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*NEW ASSET TYPE - VALUE and PERCENTAGE*/&lt;/P&gt;&lt;P&gt;%macro outbal(var);&lt;BR /&gt;proc means data=Additional_Dataset sum;&lt;BR /&gt;var balance_outstanding;&lt;BR /&gt;where &amp;amp;var.=1;&lt;BR /&gt;output out=&amp;amp;var._balance(drop=_type_ _freq_) sum=;&lt;BR /&gt;run;&lt;BR /&gt;data &amp;amp;var._balance;&lt;BR /&gt;set &amp;amp;var._balance;&lt;BR /&gt;percent=balance_outstanding/&amp;amp;total_bal.;&lt;BR /&gt;balance_outstanding=balance_outstanding/1000000;&lt;BR /&gt;run;&lt;BR /&gt;%mend (var);&lt;BR /&gt;%outbal(performing);&lt;BR /&gt;%outbal(Performing_Arr_Elsewhere);&lt;BR /&gt;%outbal(non_performing);&lt;BR /&gt;data all_new_asset_type_balance;&lt;BR /&gt;set &lt;BR /&gt;performing_balance&lt;BR /&gt;Performing_Arr_Elsewhere_balance&lt;BR /&gt;non_performing_balance;&lt;BR /&gt;run;&lt;BR /&gt;filename odata dde&lt;BR /&gt;"Excel|G:\Mortgages\Optimum\Reporting Challenger\[Co-Op MI Credit Risk.xlsx]Dashboard Data!R5C53:R7C54" notab ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;SET all_new_asset_type_balance;&lt;BR /&gt;FILE odata dlm='09'x;&lt;BR /&gt;PUT balance_outstanding percent;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;2.Macro Code for DDE to replicate as above just take away the manual intervention- &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro &lt;BR /&gt;dataset (mon, mon1, mon2);&lt;BR /&gt;data _null_;&lt;BR /&gt;call symput('offset',compress(intck('month','01jul2013'd,"&amp;amp;mon."d)+2));&amp;nbsp; /*Dataset*/&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;%put offset =&amp;amp;offset.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro freqit(var);&lt;BR /&gt;proc freq data=Additional_Dataset;&lt;BR /&gt;table &amp;amp;var./out=&amp;amp;var._count missing norow nocol nocum nopercent;&lt;BR /&gt;run;&lt;BR /&gt;data &amp;amp;var._count(drop=&amp;amp;var.);&lt;BR /&gt;set &amp;amp;var._count;&lt;BR /&gt;where &amp;amp;var.=1;&lt;BR /&gt;percent=percent/100;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%freqit(performing);&lt;BR /&gt;%freqit(Performing_Arr_Elsewhere);&lt;BR /&gt;%freqit(non_performing);&lt;BR /&gt;data all_new_asset_type_volume;&lt;BR /&gt;set &lt;BR /&gt;performing_count&lt;BR /&gt;Performing_Arr_Elsewhere_count&lt;BR /&gt;non_performing_count;&lt;BR /&gt;run;&lt;BR /&gt;filename odata dde&lt;BR /&gt;"Excel|G:\Mortgages\Optimum\Reporting Challenger\[Co-Op MI Credit Risk.xlsx]Dashboard Data!R5C&amp;amp;offset.:R7C&amp;amp;offset." notab ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;SET all_new_asset_type_volume;&lt;BR /&gt;FILE odata dlm='09'x;&lt;BR /&gt;PUT count percent;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*NEW ASSET TYPE - VALUE and PERCENTAGE*/&lt;/P&gt;&lt;P&gt;%macro outbal(var);&lt;BR /&gt;proc means data=Additional_Dataset sum;&lt;BR /&gt;var balance_outstanding;&lt;BR /&gt;where &amp;amp;var.=1;&lt;BR /&gt;output out=&amp;amp;var._balance(drop=_type_ _freq_) sum=;&lt;BR /&gt;run;&lt;BR /&gt;data &amp;amp;var._balance;&lt;BR /&gt;set &amp;amp;var._balance;&lt;BR /&gt;percent=balance_outstanding/&amp;amp;total_bal.;&lt;BR /&gt;balance_outstanding=balance_outstanding/1000000;&lt;BR /&gt;run;&lt;BR /&gt;%mend (var);&lt;BR /&gt;%outbal(performing);&lt;BR /&gt;%outbal(Performing_Arr_Elsewhere);&lt;BR /&gt;%outbal(non_performing);&lt;BR /&gt;data all_new_asset_type_balance;&lt;BR /&gt;set &lt;BR /&gt;performing_balance&lt;BR /&gt;Performing_Arr_Elsewhere_balance&lt;BR /&gt;non_performing_balance;&lt;BR /&gt;run;&lt;BR /&gt;filename odata dde&lt;BR /&gt;"Excel|G:\Mortgages\Optimum\Reporting Challenger\[Co-Op MI Credit Risk.xlsx]Dashboard Data!R5C&amp;amp;offset.:R7C&amp;amp;offset" notab ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;SET all_new_asset_type_balance;&lt;BR /&gt;FILE odata dlm='09'x;&lt;BR /&gt;PUT balance_outstanding percent;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;%dataset (&amp;amp;d1.,&amp;amp;d2.,&amp;amp;d3.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 11:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176241#M264680</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2014-10-08T11:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro data to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176242#M264681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tip: try to scale down your code as much as possible. You are likely to have more people helping you if you can avoid us test nested macros etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 11:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176242#M264681</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-10-08T11:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro data to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176243#M264682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you want a different calculation for offset. Possibly something like:&lt;/P&gt;&lt;P&gt;%let mon=01sep2013;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;call symput('offset',compress(intck('month','01jul2013'd,"&amp;amp;mon."d)*4+47));&amp;nbsp; /*Dataset*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put &amp;amp;offset.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That would always give you the correct starting column based on &amp;amp;mon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 12:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-data-to-Excel/m-p/176243#M264682</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-10-08T12:09:47Z</dc:date>
    </item>
  </channel>
</rss>

