<?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 How to create a new dataset from macro output? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415273#M67560</link>
    <description>&lt;P&gt;I have a dataset of real estate data.&amp;nbsp; I created a macro that provides the means for credit score, interest rates, and down payment percentage based on the property type.&amp;nbsp; How do I take the means of the outputs and create a new dataset that merges the four macro calls?&amp;nbsp; SAS code attached.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2017 18:20:12 GMT</pubDate>
    <dc:creator>RBRoma</dc:creator>
    <dc:date>2017-11-21T18:20:12Z</dc:date>
    <item>
      <title>How to create a new dataset from macro output?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415273#M67560</link>
      <description>&lt;P&gt;I have a dataset of real estate data.&amp;nbsp; I created a macro that provides the means for credit score, interest rates, and down payment percentage based on the property type.&amp;nbsp; How do I take the means of the outputs and create a new dataset that merges the four macro calls?&amp;nbsp; SAS code attached.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 18:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415273#M67560</guid>
      <dc:creator>RBRoma</dc:creator>
      <dc:date>2017-11-21T18:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new dataset from macro output?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415276#M67561</link>
      <description>&lt;P&gt;Include your code in the posts directly please.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many people won't download attachments and they can't be opened automatically on many devices.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 18:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415276#M67561</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-21T18:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new dataset from macro output?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415278#M67563</link>
      <description>&lt;P&gt;There's no need for macros here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take your data set, then create a new data set where the value of creditscore and interest and percentdown is set to missing if the price is &amp;lt;=800000 when proptype=1; when proptype is 2, do the same; when proptype is 3, set those variables to missing when price&amp;lt;=1000000, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run PROC SUMMARY where you state the CLASS variable is Proptype, and the VAR variables are creditscore and interest and percentdown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is sooooo much easier than doing it by macros.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 18:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415278#M67563</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-21T18:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new dataset from macro output?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415279#M67564</link>
      <description>&lt;P&gt;%Macro loan2(PropType=,Price=);&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/164022"&gt;@RBRoma&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;I have a dataset of real estate data.&amp;nbsp; I created a macro that provides the means for credit score, interest rates, and down payment percentage based on the property type.&amp;nbsp; How do I take the means of the outputs and create a new dataset that merges the four macro calls?&amp;nbsp; SAS code attached.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;%IF &amp;amp;PropType = 1 %THEN %DO;&lt;BR /&gt;PROC SORT data = loanapp;&lt;BR /&gt;BY Branch;&lt;BR /&gt;run;&lt;BR /&gt;PROC MEANS Data = loanapp mean;&lt;BR /&gt;VAR CreditScore Interest PercentDown;&lt;BR /&gt;Where PropType = &amp;amp;PropType AND Price &amp;gt; &amp;amp;Price;&lt;BR /&gt;By Branch;&lt;BR /&gt;Title "Mean of Credit Score, Interest Rate, and Down Payment&lt;BR /&gt;of Property Type &amp;amp;PropType greater than &amp;amp;Price Sale Price";&lt;BR /&gt;output out = loan_out;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %if &amp;amp;PropType ^= 1 %THEN %DO;;&lt;BR /&gt;PROC MEANS Data = loanapp mean;&lt;BR /&gt;VAR CreditScore Interest PercentDown;&lt;BR /&gt;Where PropType = &amp;amp;PropType AND Price &amp;gt; &amp;amp;Price;&lt;BR /&gt;Title "Mean of Credit Score, Interest Rate, and Down Payment&lt;BR /&gt;of Property Type &amp;amp;PropType greater than &amp;amp;Price Sale Price";&lt;BR /&gt;output out=loan_out;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%Mend loan2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data loanapp;&lt;BR /&gt;set '/folders/myshortcuts/SAS/SAS HW #4/Data_Assignment4/loanapp.sas7bdat';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%loan2(PropType = 1, Price = 800000);&lt;BR /&gt;%loan2(PropType = 2, Price = 800000);&lt;BR /&gt;%loan2(PropType = 3, Price = 1000000);&lt;BR /&gt;%loan2(PropType = 4, Price = 1200000);&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 18:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415279#M67564</guid>
      <dc:creator>RBRoma</dc:creator>
      <dc:date>2017-11-21T18:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new dataset from macro output?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415290#M67565</link>
      <description>&lt;P&gt;You could try just adding a PROC APPEND to your macro so that you can aggregate the individual output datasets into a single output dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can probably just get PROC MEANS to generate everything in one call if you setup the data properly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To remove the BRANCH variable from the grouping variables for some of the PROPTYPE values you can just set it to missing.&lt;/P&gt;
&lt;P&gt;Looks like this is what you want to do;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_analysis ;
   set loanapp;
   if PropType in (1,2,3,4);

   if PropType = 1 then cutoff = 800000;
   if PropType = 2 then cutoff = 800000;
   if PropType = 3 then cutoff = 1000000;
   if PropType = 4 then cutoff = 1200000;
   if price &amp;gt; cutoff ;

   if  not (PropType=1) then call missing(branch);
run;

proc means data=for_analysis mean nway missing;
  class proptype cutoff branch ;
  var CreditScore Interest PercentDown;
  output out = loan_out;
Title1 "Mean of Credit Score, Interest Rate, and Down Payment";
Title2 "of Property with Sale Price Greater than CUTOFF";
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 19:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-new-dataset-from-macro-output/m-p/415290#M67565</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-21T19:21:23Z</dc:date>
    </item>
  </channel>
</rss>

